Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

How to save grayscale image data?

Anonymous75
Beginner
343 Views

I wanna save image data in grayscale. I set the parameters as below. But the program always exits at the line "ijlWrite()". What is up?

image.DIBColor = IJL_G;//

image.DIBChannels = 1;

image.DIBPadBytes = IJL_DIB_PAD_BYTES(image.DIBWidth,1);

image.JPGColor = IJL_G;

image.JPGChannels = 1;

image.JPGSubsampling = IJL_NONE;

//////////////////////////////////////

For more details , please check the following code as below:

if( ijlInit( ℑ ) != IJL_OK )

{

TRACE( "Can't initialize Intel JPEG library " );

return ;

}

image.DIBWidth = nWidth;

image.DIBHeight = nHeight;

image.DIBBytes = pImgBuf;

// Setup JPEG

image.JPGFile =

const_cast<char*>("f:\11.jpg");

image.JPGWidth = nWidth;

image.JPGHeight = nHeight;

image.DIBColor = IJL_G;

image.DIBChannels = 1;

image.DIBPadBytes = IJL_DIB_PAD_BYTES(image.DIBWidth,1);

image.JPGColor = IJL_G;

image.JPGChannels = 1;

image.JPGSubsampling = IJL_NONE;

if( ijlWrite( ℑ, IJL_JFILE_WRITEWHOLEIMAGE ) != IJL_OK )

{

TRACE( "Can't write image " );

return ;

}

if( ijlFree( ℑ ) != IJL_OK )

{

TRACE( "Can't free Intel JPEG library " );

return ;

}

0 Kudos
3 Replies
Vladimir_Dudnik
Employee
343 Views

Hi,

code looks OK, probably you did not provide enough memory buffer. By the way, ijlWrite() function return error code which you can look at to get an idea what is the problem

Regards,
Vladimir

0 Kudos
naoki_moriuchi
Beginner
343 Views

Hi, this is Naoki Moriuchi from Japan.

I think your problem is caused by IJL_DIB_PAD_BYTES macro.
Please try the following code for DIBPadBytes.
----------------------------------------------------------------------------------
int bitmap_width = ((jcprops.DIBWidth * 8 + 31) / 32) * 4;

jcprops.DIBPadBytes = (bitmap_width - jcprops.DIBWidth) * jcprops.DIBChannels;

----------------------------------------------------------------------------------

naoki_moriuchi@nifty.com
0 Kudos
Vladimir_Dudnik
Employee
344 Views

Naoki,

IJL_DIB_PAD_BYTES should do the same calculations. I think it is possible to learn more if analise ijlWrite return code.

Regards,
Vladimir

0 Kudos
Reply