데이터베이스에서 jpeg 이미지를 표시하는 Win32 기반 응용 프로그램을 작성하고 있습니다. 나는 디코더로 libjpeg를 고르지 만 대부분의 이미지는 잘못 표시됩니다. 이미지의 너비를 1 씩 늘리거나 줄여서 고칠 수 있지만이 수정 이후 제대로 표시되지 않는 이미지는 올바르게 표시됩니다. 여기 (BGR 변환 RGB 제외) 내 코드의 일부 :libjpeg/CreateDIBSection 문제
int JpegToRaw(BYTE *input, int insize, BYTE *output, int &width, int &height)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_mem_src(&cinfo, input, insize);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
//--cinfo.output_width; or ++cinfo.output_width;
int row_stride = cinfo.output_width * 3;
int outsize = row_stride * cinfo.output_height;
output = (BYTE *)malloc(outsize * sizeof(BYTE));
BYTE *pos = output;
while (cinfo.output_scanline < cinfo.output_height)
{
jpeg_read_scanlines(&cinfo, &pos, 1);
pos += row_stride;
}
width = cinfo.output_width;
height = cinfo.output_height;
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
return outsize;
}
HBITMAP RawToBitmap(BYTE *input, int size, int width, int height)
{
BITMAPINFO bi;
bi.bmiHeader.biSize = sizeof(bi24BitInfo.bmiHeader);
bi.bmiHeader.biWidth = width;
bi.bmiHeader.biHeight = -height;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 24;
bi.bmiHeader.biCompression = BI_RGB;
HBITMAP hBitmap = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, NULL, NULL, 0);
SetBitmapBits(hBitmap, size, input);
return hBitmap;
}
내가 JpegToRaw()
에 유효한 JPEG 배열을 통과 확신 해요,하지만 난 이미지가 다른 표시 할 이유를 모르겠어요. 누군가 그것을 얻을 수 있도록 도와 줄 수 있습니까? DIB를 약
나는이 중요한 사실을 간과 할 수 있다고 믿을 수 없습니다! 정말 고맙습니다! – Joulukuusi