Slion.net>Dev>LipJpeg

LipJpeg

I've been using libjpeg for some projects like MilkShapeViewer.

Dealing with JERR_BAD_STRUCT_SIZE error

When moving to libjpeg V7.0 it reported JERR_BAD_STRUCT_SIZE errors when trying to load any JPEG for win32 builds. Turns out the problem was due to the fact that libjpeg defines boolean as int when Windows defines it as unsigned char. Adding the following code to jmorecfg.h fixed my issue:

#ifndef HAVE_BOOLEAN
//SL: fixing silly issue giving JERR_BAD_STRUCT_SIZE error
#   ifdef _WINDOWS
typedef unsigned char boolean;
#   else
typedef int boolean;
#   endif
#endif
#ifndef FALSE         /* in case these macros already exist */
#define FALSE   0      /* values of boolean */
#endif
#ifndef TRUE
#define TRUE   1
#endif

See also that issue discussed there.