Hello,
Has anyone been through the process of converting C or C++ code which performed JPEG compression and decompression using IJL to using IPP? In particular, we create buffers of data to be compressed and decompressed since we have proprietary file formats. Below is a section of the code which compress a buffer. Note, this is a method in a class and some of the data is set in the class constructor.
As you will see, this code is very clean and simple unlike the IPP examples which seem to be only file based, i.e. reading headers and writing data to files, and also more complex. The documentation is also vast and broken up into small sections. So far it seems impenetrable.
I will be most grateful for some guidance to usage documentation or an example.
Thank you.
uint32
JpegCompressor::compress( uint8* buffer, uint32 factor,
uint16 photometric_interpretation )
{
JPEG_CORE_PROPERTIES jcprops;
IJLERR stat;
if ((stat = ijlInit(&jcprops)) != IJL_OK)
{
const char* err = (const char*)ijlErrorStr(stat);
cerr << "IJLError: "<< err << " UNABLE TO INIT JPEG CORE PROPS\n";
ijlFree(&jcprops);
return -1;
}
jcprops.DIBWidth = width;
jcprops.DIBHeight = height;
jcprops.DIBChannels = bands;
jcprops.DIBColor = ( bands == 1 ) ? IJL_G : IJL_RGB;
jcprops.DIBPadBytes = 0;
jcprops.DIBBytes = buffer;
int buffer_size = width*height*bands;
compressed_data = new uint8 [buffer_size];
jcprops.JPGBytes = compressed_data;
jcprops.JPGSizeBytes = buffer_size;
jcprops.JPGWidth = width;
jcprops.JPGHeight = height;
jcprops.JPGChannels = bands;
IJL_COLOR out_photometric = IJL_G;
if(bands == 3)
{
out_photometric = (photometric_interpretation == PHOTOMETRIC_RGB) ?
IJL_RGB : IJL_YCBCR;
}
jcprops.JPGColor = out_photometric;
jcprops.JPGSubsampling = (IJL_JPGSUBSAMPLING) IJL_NONE;
jcprops.jquality = factor;
if((stat = ijlWrite(&jcprops, IJL_JBUFF_WRITEWHOLEIMAGE)) != IJL_OK)
{
const char* err = (const char*)ijlErrorStr(stat);
cerr << "IJLError: "<< err << " UNABLE TO COMPRESS JPEG IMAGE\n";
ijlFree(&jcprops);
return -1;
}
compressed_size = jcprops.JPGSizeBytes;
ijlFree(&jcprops);
return compressed_size;
}
We have lived happily with this old library but now plan to build a 64bit application and so we must upgrade to IPP.