From 3270641c60fa5bba94e81589c74c557fdedd29ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Belleng=C3=A9?= Date: Thu, 8 May 2003 17:35:12 +0000 Subject: [PATCH] - Fix scanline size in OLEPictureImpl_Load for jpeg - Convert from RGB to BGR according to BITMAPINFOHEADER documentation. --- dlls/oleaut32/olepicture.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c index 2567591861f..e20d54320e3 100644 --- a/dlls/oleaut32/olepicture.c +++ b/dlls/oleaut32/olepicture.c @@ -990,11 +990,13 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) { struct jpeg_error_mgr jerr; int ret; JDIMENSION x; - JSAMPROW samprow; + JSAMPROW samprow,oldsamprow; BITMAPINFOHEADER bmi; LPBYTE bits; HDC hdcref; struct jpeg_source_mgr xjsm; + LPBYTE oldbits; + int i; /* This is basically so we can use in-memory data for jpeg decompression. * We need to have all the functions. @@ -1011,25 +1013,37 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface,IStream*pStm) { jpeg_create_decompress(&jd); jd.src = &xjsm; ret=jpeg_read_header(&jd,TRUE); + jd.out_color_space = JCS_RGB; jpeg_start_decompress(&jd); if (ret != JPEG_HEADER_OK) { ERR("Jpeg image in stream has bad format, read header returned %d.\n",ret); HeapFree(GetProcessHeap(),0,xbuf); return E_FAIL; } - bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(jd.output_height+1)*jd.output_width*jd.output_components); + + bits = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY, + (jd.output_height+1) * ((jd.output_width*jd.output_components + 3) & ~3) ); samprow=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,jd.output_width*jd.output_components); + + oldbits = bits; + oldsamprow = samprow; while ( jd.output_scanline