Opening JPEG images.
I have been given a project that includes a .rpc file. In the file is information about a JPEG image and the image itself. I can open this file and get all kinds of information about the image but I don''t know how to display the JPEG image itself. Please help, I have been working on this for over a month.
Axel
Axel
libjpeg from http://www.ijg.org/ will let you do what you want in a couple of function calls. I was messing around with it trying to get it to dump the rendering window, and it works really well. I think I will try and modify lesson 6 to read the texture from a jpeg, and post the results if I get it to work.
November 01, 2000 04:47 PM
Rohar,
When you modify what lesson 6 to work with JPEG can you forward me the changes in the code.
Axel
When you modify what lesson 6 to work with JPEG can you forward me the changes in the code.
Axel
this will prettymuch drop in for loadBMP, and load the texture from a jpeg. It works, but I didn't put alot of time into error checking, I will when I get a chance. There is a whack of info returned from the libjpeg library, which should be error checked for correctness....
You need to link with libjpeg.lib & have the headers. (I built my own libjpeg library from the source @ http://www.ijg.org/ for vc on win98, but it also works on my RH6.2 box with the included libjpeg library)
Make sure you use a 256x256x24 RGB JFIF jpeg... and you should be okey-dokey. (I just converted the NeHe bmp to a jpeg with no changes)
The dumb-assed looking math where I am swapping the buffer is because the image loads upside down. The row pointer array is because libjpeg needs a pointer array, and can return more than 1 line at a time... When I understand the library better, I think that the temp buffer can get turfed, and more than 1 line can be processed at a time. (array of pointers to the output buffer, and change them with each call to jpeg_read_scanlines)
The docs that come with libjpeg are pretty good.
If you don't mind... don't pick on my code, I did this from scratch in an hour and it even works![](smile.gif)
you'll need to wrap extern "C" { } around the c includes for vc
Edited by - rohar on November 1, 2000 7:48:28 PM
You need to link with libjpeg.lib & have the headers. (I built my own libjpeg library from the source @ http://www.ijg.org/ for vc on win98, but it also works on my RH6.2 box with the included libjpeg library)
Make sure you use a 256x256x24 RGB JFIF jpeg... and you should be okey-dokey. (I just converted the NeHe bmp to a jpeg with no changes)
The dumb-assed looking math where I am swapping the buffer is because the image loads upside down. The row pointer array is because libjpeg needs a pointer array, and can return more than 1 line at a time... When I understand the library better, I think that the temp buffer can get turfed, and more than 1 line can be processed at a time. (array of pointers to the output buffer, and change them with each call to jpeg_read_scanlines)
The docs that come with libjpeg are pretty good.
If you don't mind... don't pick on my code, I did this from scratch in an hour and it even works
![](smile.gif)
you'll need to wrap extern "C" { } around the c includes for vc
|
Edited by - rohar on November 1, 2000 7:48:28 PM
rohar -> Thanks for your code...
But I couldn''t compile it... I done something wrong when I used it. The linker give me this messages:
"void __cdecl jpeg_destroy_decompress(struct jpeg_decompress_struct *)" (?jpeg_destroy_decompress@@YAXPAUjpeg_decompress_struct@@@Z)
"unsigned char __cdecl jpeg_finish_decompress(struct jpeg_decompress_struct *)" (?jpeg_finish_decompress@@YAEPAUjpeg_decompress_struct@@@Z)
"unsigned int __cdecl jpeg_read_scanlines(struct jpeg_decompress_struct *,unsigned char * *,unsigned int)" (?jpeg_read_scanlines@@YAIPAUjpeg_decompress_struct@@PAPAEI@Z)
"unsigned char __cdecl jpeg_start_decompress(struct jpeg_decompress_struct *)" (?jpeg_start_decompress@@YAEPAUjpeg_decompress_struct@@@Z)
"int __cdecl jpeg_read_header(struct jpeg_decompress_struct *,unsigned char)" (?jpeg_read_header@@YAHPAUjpeg_decompress_struct@@E@Z)
"void __cdecl jpeg_stdio_src(struct jpeg_decompress_struct *,struct _iobuf *)" (?jpeg_stdio_src@@YAXPAUjpeg_decompress_struct@@PAU_iobuf@@@Z)
"void __cdecl jpeg_CreateDecompress(struct jpeg_decompress_struct *,int,unsigned int)" (?jpeg_CreateDecompress@@YAXPAUjpeg_decompress_struct@@HI@Z)
"struct jpeg_error_mgr * __cdecl jpeg_std_error(struct jpeg_error_mgr *)" (?jpeg_std_error@@YAPAUjpeg_error_mgr@@PAU1@@Z)
Or short, the linker couldn''t find the stuff.
I used the Libjpeg.lib (wrong version??) but the linker couldn''t find the stuff.
Can you help me to solve this ''little'' problem?
Thanks
But I couldn''t compile it... I done something wrong when I used it. The linker give me this messages:
"void __cdecl jpeg_destroy_decompress(struct jpeg_decompress_struct *)" (?jpeg_destroy_decompress@@YAXPAUjpeg_decompress_struct@@@Z)
"unsigned char __cdecl jpeg_finish_decompress(struct jpeg_decompress_struct *)" (?jpeg_finish_decompress@@YAEPAUjpeg_decompress_struct@@@Z)
"unsigned int __cdecl jpeg_read_scanlines(struct jpeg_decompress_struct *,unsigned char * *,unsigned int)" (?jpeg_read_scanlines@@YAIPAUjpeg_decompress_struct@@PAPAEI@Z)
"unsigned char __cdecl jpeg_start_decompress(struct jpeg_decompress_struct *)" (?jpeg_start_decompress@@YAEPAUjpeg_decompress_struct@@@Z)
"int __cdecl jpeg_read_header(struct jpeg_decompress_struct *,unsigned char)" (?jpeg_read_header@@YAHPAUjpeg_decompress_struct@@E@Z)
"void __cdecl jpeg_stdio_src(struct jpeg_decompress_struct *,struct _iobuf *)" (?jpeg_stdio_src@@YAXPAUjpeg_decompress_struct@@PAU_iobuf@@@Z)
"void __cdecl jpeg_CreateDecompress(struct jpeg_decompress_struct *,int,unsigned int)" (?jpeg_CreateDecompress@@YAXPAUjpeg_decompress_struct@@HI@Z)
"struct jpeg_error_mgr * __cdecl jpeg_std_error(struct jpeg_error_mgr *)" (?jpeg_std_error@@YAPAUjpeg_error_mgr@@PAU1@@Z)
Or short, the linker couldn''t find the stuff.
I used the Libjpeg.lib (wrong version??) but the linker couldn''t find the stuff.
Can you help me to solve this ''little'' problem?
Thanks
The library is compiled without a extern "C" {...} when linked into c++.
You need to wrap extern "C" around the includes when you compile & link with vc++.
This should really be in the jpeglib.h, but it isn't.
Edited by - rohar on November 6, 2000 9:23:39 PM
You need to wrap extern "C" around the includes when you compile & link with vc++.
|
This should really be in the jpeglib.h, but it isn't.
Edited by - rohar on November 6, 2000 9:23:39 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement