Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
공지
Important Update: Community Platform Migration​. Learn more​>

How to save grayscale image data?

Anonymous75
초급자
1,969 조회수

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 포인트
3 응답
Vladimir_Dudnik
1,969 조회수

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 포인트
naoki_moriuchi
초급자
1,969 조회수

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;

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

0 포인트
Vladimir_Dudnik
1,970 조회수

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 포인트
응답