;
rows = DeComInfo.output_width * DeComInfo.output_components;
pBuffer = (*DeComInfo.mem->alloc_sarray)
((j_common_ptr) &DeComInfo, JPOOL_IMAGE, rows, 1);
//读取扫描线
while (DeComInfo.output_scanline < DeComInfo.output_height)
{
(void) jpeg_read_scanlines(&DeComInfo, pBuffer, 1);
if (DeComInfo.out_color_components==3)
{
Scanline(pBuffer[0],
bmpWidth,
pData,
DeComInfo.output_scanline-1);
}
else if (DeComInfo.out_color_components==1)
{
ScanlineToRGB(pBuffer[0],
bmpWidth,
pData,
DeComInfo.output_scanline-1);
}
}
//完成解压
(void) jpeg_finish_decompress(&DeComInfo);
//释放JPEG解压对象
jpeg_destroy_decompress(&DeComInfo);
fclose(pFile);
return pData;
}
void CCompressJpegDlg::ConvertRGB(unsigned char *pBuf, UINT Width, UINT Height)
{
UINT col, row;
for ( row=0 ; row<Height ; row++)
{
for (col=0; col<Width; col++)
{
unsigned char* pRed, *pGrn, *pBlu;
pRed = pBuf + row * Width * 3 + col * 3;
pGrn = pBuf + row * Width * 3 + col * 3 + 1;
pBlu = pBuf + row * Width * 3 + col * 3 + 2;
unsigned char unChar;
unChar = *pRed;
*pRed = *pBlu;
*pBlu = unChar;
}
}
}
#define BYTENUM(bitdata) (((bitdata) + 31) / 32 * 4)
unsigned char* CCompressJpegDlg::DataAlign(unsigned char *pData, int Width, int Height, int *pOutWidth)
{
if (pData==NULL)
return NULL;
UINT WidthBytes;
WidthBytes = BYTENUM(Wi
上一篇:
CompressJpeg.cpp
下一篇:
荷兰留学生课程作业 competitive Marketing Strategy As