jpeglib question

Hi there!

I assume, a lot of you are using the intel jpeglib. There is an error that gives me a headache since a few hours.

I declare a cinfo struct like this:
struct jpeg_decompress_struct cinfo;

and create the decompression object from it with this function:
jpeg_create_decompress( &cinfo );

and in this function (file: jdapimin.c) my program always exits at this if():
if (structsize != SIZEOF(struct jpeg_decompress_struct))
{
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
(int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);
}

passed structsize parameter is 432
SIZEOF(struct jpeg_decompress_struct) is 464

How can this occur? i mean…all datas are from ‘struct jpeg_decompress_struct’?
Did someone of you already had this problem?
or can you give me a hint? This drives me crazy!!
I am working as a software developer since 1998, but i never had a prob like this before!!

oh BTW: iam using JPEG_LIB_VERSION 62

thank you guys for your help!

  • Christoph -

This structsize variable … where does it come from and when and what do you assign it?

I don’t understand why people don’t just use DevIL. It’s free for commercial use, as far as I know - it’s very robust, straightforward to use and works as a state machine. It supports just about any image format you can think of. Just link to it and forget about image loading for good.
Is there a particular reason why more people don’t use it?

Hello!

Knackered: There’s the problem. As you mentioned “It’s free for commercial use”.
And I do not “just play around” with OpenGL, do not share my source or copy & paste source from others!!
There are not so many questions from a publisher if you use your own stuff!

Humus: ‘structsize’ is a function-paramter from ‘jpeg_CreateDecompress(…)’ and will be passed thru the ‘jpeg_create_decompress( &cinfo )’ makro (file: jpeglib.h) at the beginning of my very own JPG loading code.

Hope it helps.

  • Christoph -

Eh? Copy & paste? Using a standard library for doing something as mundane and unchanging as loading fixed file formats into an area of memory is copy & paste coding?
You’re using the Intel jpeg library, so why is this different to using DevIL? Except you’re limited to jpegs, which don’t contain alpha.
I’m a commercial graphics programmer too, but don’t see any problems in using open source stuff if its proven to be robust.

a misunderstanding!

when i hear “copy&paste coding” i mean copying code snippets into the own code, compile it and say “that’s mine”. And i know enough guys which do this and bother the coder with questions like “why does this not work with my code?”. look into this forum. so many people are downloading NeHe’s tuts and post messages here that it does not work!! I mean come on…just creating a new file and compile it will never work without setting the linker-properties!
But let’s stop this topic. To continue, it’s better to e-mail…

Currently, i have my own PNG, TGA, TIFF and BMP loading code. Now i want to add JPG support to my engine! That’s it.
And the reason why i don’t want to use DevIL is really simple: I only code what i really need! I assume DevIL is a very powerful libary, so it will take too much time to get familiar with it!

Have you an idea what’s wrong in my (original posted) problem?

friendly regards,

  • Christoph -

No, no idea - I use DevIL!
Good luck writing your sound drivers!

Intel JPEG library is probably faster than DevIL.

However, the problem with DevIL is not the “extent” of the library, but the lack of an actual example in the documentation/tutorial. There’s a few things which are left unsaid, and assumed. However, once you’re over that hump, it really isn’t that big a deal to get into it. There’s even a pre-compiled DLL for Windows.

Here’s some code you can copy & paste if you want :slight_smile: (complete with assertions for error reporting, no return code, implicit use of std:: and everything!)

void loadTexture( string const & n, GLuint tex )
{
assert( tex );

int xSize, ySize, rowBytes;

ILuint im;
ilGenImages( 1, &im );
ilBindImage( im );
ilEnable( IL_FORMAT_SET );
ilSetInteger( IL_FORMAT_MODE, IL_BGRA );
ilEnable( IL_TYPE_SET );
ilSetInteger( IL_TYPE_MODE, IL_UNSIGNED_BYTE );
ilEnable( IL_ORIGIN_SET );
ilSetInteger( IL_ORIGIN_MODE, IL_ORIGIN_LOWER_LEFT );
ilEnable( IL_CONV_PAL );
assert( !ilGetError() );
ilLoadImage( (char *)n.c_str() );
if( ilGetError() ) {
ilDeleteImages( 1, &im );
goto failure;
}
xSize = ilGetInteger( IL_IMAGE_WIDTH );
ySize = ilGetInteger( IL_IMAGE_HEIGHT );
rowBytes = xSize * ilGetInteger( IL_IMAGE_BYTES_PER_PIXEL );
glBindTexture( GL_TEXTURE_2D, tex );
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, xSize, ySize, 0, GL_BGRA, GL_UNSIGNED_BYTE, ilGetData() );
ilDeleteImages( 1, &im );
return;

failure:
assert( !“loading this texture didn’t work” );
return;
}

Oh, another thing:

When you download the Intel libraries from their site, you can register for their “premium support”. Which is free. And answers questions specifically about the Intel libraries.

Believe it or not!

I think the intel jpeg library comes at a cost now. I have used it for a couple of years but I’m considering dropping it for libjpeg or maybe even go for DevIL. Probably devil. Anyone know if there is support for GIF and animated GIF?

There is support for 32 bpp JPEGs with Intel!

V-man

Yes, DevIL supports all that stuff. It’s really complete, and very opengl-like.

Anyway, I think it uses either libjpeg or the intel lib for loading jpegs.

I just wish it could support those old .cel files that used to come with 3DStudio…