C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-30-2009, 07:46 AM   #16
Registered User
 
Join Date: Jun 2009
Posts: 14
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
TranT is offline   Reply With Quote
Old 06-30-2009, 08:08 AM   #17
Registered User
 
Join Date: Jun 2009
Posts: 14
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?
TranT is offline   Reply With Quote
Old 06-30-2009, 08:09 AM   #18
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
Quote:
Originally Posted by TranT View Post
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
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.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is online now   Reply With Quote
Old 06-30-2009, 08:16 AM   #19
Jaxom's & Imriel's Dad
 
Kennedy's Avatar
 
Join Date: Aug 2006
Location: Alabama
Posts: 801
Quote:
Originally Posted by MK27 View Post
I was just looking at your pastebin code again. I don't think "wb" is a proper argument to fwrite() -- it is just for the lowest level write(). Anyway, going by my example, it is not necessary, so try with just "w".
If you are talking about these two lines of code:
Code:
img = fopen("teste.jpeg","wb");
fwrite(pic.picture,1,pic.piclength,img);
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).
Kennedy is offline   Reply With Quote
Old 06-30-2009, 08:16 AM   #20
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
Quote:
Originally Posted by TranT View Post
As i saw i must get that 32bit offset. How am i suposed to copy data from the picture buffer starting on that offset?
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:
Code:
struct jpeg2000 {
      unsigned char type;
      unsigned char type-specific;
      unsigned char priority;
      int X_id:5;   /* :5 is the bit length */
      int offset;
}
"offset" would be that number, altho there may be some complications with compiler padding. But again: you don't have to do this!

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.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS

Last edited by MK27; 06-30-2009 at 08:21 AM.
MK27 is online now   Reply With Quote
Old 06-30-2009, 08:30 AM   #21
Registered User
 
Join Date: Jun 2009
Posts: 14
OK then .. I got both imageinfo and picture into separate buffers.. now how can i merge them as in array.copy in JAVA : )?
TranT is offline   Reply With Quote
Old 06-30-2009, 08:36 AM   #22
Registered User
 
Join Date: Jun 2009
Posts: 14
nvm the question lol i did it manually : pastebin - collaborative debugging tool but still not working :x
TranT is offline   Reply With Quote
Old 06-30-2009, 08:42 AM   #23
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
Quote:
Originally Posted by TranT View Post
OK then .. I got both imageinfo and picture into separate buffers.. now how can i merge them as in array.copy in JAVA : )?
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:
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;
}
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.

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.
Code:
memcpy(&buffer[666], from, size);
Where "666" is the end of the first memcpy.

[edit] looks like you already did this last part, or something sufficiently similar. So look for those two bytes...
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS

Last edited by MK27; 06-30-2009 at 08:46 AM.
MK27 is online now   Reply With Quote
Old 06-30-2009, 08:55 AM   #24
Registered User
 
Join Date: Jun 2009
Posts: 14
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
TranT is offline   Reply With Quote
Old 06-30-2009, 09:07 AM   #25
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
Quote:
Originally Posted by TranT View Post
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.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS

Last edited by MK27; 06-30-2009 at 09:10 AM.
MK27 is online now   Reply With Quote
Old 06-30-2009, 10:56 AM   #26
Registered User
 
Join Date: Jun 2009
Posts: 14
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 : )
TranT is offline   Reply With Quote
Old 06-30-2009, 02:47 PM   #27
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
Quote:
Originally Posted by TranT View Post
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 : )
I just want to make it clear at this point to any interested international authorities that I was *not* knowingly involved in this event.

ps. @ TranT -- you need to get a new cboard id and start a different thread.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is online now   Reply With Quote
Old 06-30-2009, 03:30 PM   #28
Registered User
 
Join Date: Sep 2008
Location: Toronto, Canada
Posts: 507
You should open the file with
Code:
fopen(argv[1],"rb")
And likewise create/open the destination file with "wb". Plus it's always good practice to fclose() the new file as well.
nonoob is offline   Reply With Quote
Old 07-01-2009, 02:44 AM   #29
Registered User
 
Join Date: Jun 2009
Posts: 14
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
TranT is offline   Reply With Quote
Old 07-01-2009, 03:15 AM   #30
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 4,923
>> 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.
Sebastiani is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Another syntax error caldeira C Programming 31 09-05-2008 01:01 AM
C++ ini file reader problems guitarist809 C++ Programming 7 09-04-2008 06:02 AM
Game Pointer Trouble? Drahcir C Programming 8 02-04-2006 02:53 AM
Need help understanding info in a header file hicpics C Programming 8 12-02-2005 12:36 PM
File Input / Output Help? Unregistered C Programming 3 05-18-2002 10:20 AM


All times are GMT -6. The time now is 08:04 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22