I will try to join the 2 imageinfo+picture to see if works..
I tried to do that print u made and i got this weird result:
for pic->imageinfo[0] = 2 and pic->imageinfo[1]=1
for pic->picture[0]=0 and pic->picture[2]=0 and pic->picture[3]=0
:S
I will try to join the 2 imageinfo+picture to see if works..
I tried to do that print u made and i got this weird result:
for pic->imageinfo[0] = 2 and pic->imageinfo[1]=1
for pic->picture[0]=0 and pic->picture[2]=0 and pic->picture[3]=0
:S
JPEG 2000 payload header
As i saw i must get that 32bit offset. How am i suposed to copy data from the picture buffer starting on that offset?
Hmmm. Well, I tried this on a bunch of jpegs and they all have the same first two bytes (0xffffffff then 0xffffffd8). For an unsigned char, that means 255 and 216, for a (signed) char -1 and -40.
I'll check and see if these are prone to repeat inside of the image; if not, you could just scan the whole thing to find the start of the jpeg.
Part of the reason why I asked if you are "hacking" (in the good sense) is because if you don't have an API which explicitly says these structs will deliver a jpeg encoded image, you might have made a conceptual leap. It may be true that "the picture is compressed in JPEG/JPEG2000", but that does not mean that the struct delivered by PTEID_GetPic() keeps it that way.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
If you are talking about these two lines of code:Sure it is. "wb" in the WINDOWS world means "write binary" and ONLY tells that stupid OS to NOT convert "\n" to "\r\n". In the Linux world, it is completely pointless and ignored by the OS (as all files are written without EVER being converted by the OS, just the app).Code:img = fopen("teste.jpeg","wb"); fwrite(pic.picture,1,pic.piclength,img);
You don't have to, but if you did this is how it would work: supposedly there is a 4-byte integer (32 bits!) starting at bit 29 (that's crazy) which contains the offset. However, I think you are looking at something to do with jpeg video...but you would want to create a struct corresponding to all that:
"offset" would be that number, altho there may be some complications with compiler padding. But again: you don't have to do this!Code:struct jpeg2000 { unsigned char type; unsigned char type-specific; unsigned char priority; int X_id:5; /* :5 is the bit length */ int offset; }
Anyway, those things are part of the header which your image viewer program needs to interpret the image correctly. You want to include, not exclude the header, so you don't have to worry about separating it.
Last edited by MK27; 06-30-2009 at 08:21 AM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
OK then .. I got both imageinfo and picture into separate buffers.. now how can i merge them as in array.copy in JAVA : )?
nvm the question lol i did it manually : pastebin - collaborative debugging tool but still not working :x
Why don't you check them first to see if this is jpeg data at all? I just used this on a whole directory of photographs:
12 megs, 265 files and every single one printed "byte 0", meaning all jpegs begin that way, and that sequence does not repeat anywhere inside the file.Code:#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int size, i=0; unsigned char image[1000000] = {0}; FILE *in = fopen(argv[1],"r"); size = fread(image,1,1000000,in); fclose(in); while (i<size-1) { if ((image[i]==255) && (image[i+1]==216)) printf("byte %d\n",i); i++; } return 0; }
So adapt that while loop and try it.
As for concatenating char arrays, just make one big buffer and then use memcpy(). You cannot use strcpy() or strcat() because the image data will have '\0' bytes in it. For the second memcpy, you want the destination to be an offset into the big buffer, eg.
Where "666" is the end of the first memcpy.Code:memcpy(&buffer[666], from, size);
[edit] looks like you already did this last part, or something sufficiently similar. So look for those two bytes...
Last edited by MK27; 06-30-2009 at 08:46 AM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
i made prints for all the PTEID_PIC data: pastebin - collaborative debugging tool
I scanned the whole picture data and didn't found any 0xFFD8 from JPEG :X but this has to be some kind of image :/ lol
Sigh. That's what I was afraid of. You may have to email the people who wrote the software at this point; just be succinct and say what you want to do, what you've tried, and in what format does that function return?
If it is software that came with hardware, you probably won't get an answer because manufacturers aren't programmers and they are usually not interested in your problems. Otherwise you probably will get some advice, since evidently the source is open.
Last edited by MK27; 06-30-2009 at 09:10 AM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
The stupid thing about this is that this is the Portuguese Citizen Smartcard so this was "done" by the government lol will try to contact the developers then
Thanks for all the help : )
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
You should open the file with
And likewise create/open the destination file with "wb". Plus it's always good practice to fclose() the new file as well.Code:fopen(argv[1],"rb")
MK27 I am not exploiting in any way the smartcard i am just trying to get the image of it and thats legal so you don't have to be worrying about anything lol
cheers
>> MK27 I am not exploiting in any way the smartcard i am just trying to get the image of it and thats legal so you don't have to be worrying about anything
I'm afraid you're too late. He's already changed his name and moved to Yonkers, holed up in a little cabin by the river. But no worries, I'm sure he's much happier there.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }