From: Daniel Lehman dlehman25@gmail.com
--- dlls/oleaut32/olepicture.c | 30 ++++++++++++++++-------------- dlls/oleaut32/tests/olepicture.c | 8 ++++---- 2 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c index e4bfafe6fd0..72396a91752 100644 --- a/dlls/oleaut32/olepicture.c +++ b/dlls/oleaut32/olepicture.c @@ -983,25 +983,27 @@ static HRESULT WINAPI OLEPictureImpl_IsDirty(
static HRESULT OLEPictureImpl_LoadDIB(OLEPictureImpl *This, BYTE *xbuf, ULONG xread) { - BITMAPFILEHEADER *bfh = (BITMAPFILEHEADER*)xbuf; - BITMAPINFO *bi = (BITMAPINFO*)(bfh+1); - HDC hdcref; + BITMAPFILEHEADER *bfh = (BITMAPFILEHEADER*)xbuf; + BITMAPINFO *bi = (BITMAPINFO*)(bfh+1); + HDC hdcref; + HBITMAP hbmp; + void *bits = NULL;
/* Does not matter whether this is a coreheader or not, we only use * components which are in both */ - hdcref = GetDC(0); - This->desc.bmp.hbitmap = CreateDIBitmap( - hdcref, - &(bi->bmiHeader), - CBM_INIT, - xbuf+bfh->bfOffBits, - bi, - DIB_RGB_COLORS - ); - ReleaseDC(0, hdcref); - if (This->desc.bmp.hbitmap == 0) + hdcref = CreateCompatibleDC(0); + hbmp = CreateDIBSection(hdcref, bi, DIB_RGB_COLORS, &bits, NULL, 0); + if (hbmp && !SetDIBits(hdcref, hbmp, 0, bi->bmiHeader.biHeight, + xbuf + bfh->bfOffBits, bi, DIB_RGB_COLORS)) + { + DeleteObject(hbmp); + hbmp = 0; + } + DeleteDC(hdcref); + if (!hbmp) return E_FAIL; + This->desc.bmp.hbitmap = hbmp; This->desc.picType = PICTYPE_BITMAP; OLEPictureImpl_SetBitmap(This); return S_OK; diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c index 0fb308f5d2f..281040845c0 100644 --- a/dlls/oleaut32/tests/olepicture.c +++ b/dlls/oleaut32/tests/olepicture.c @@ -1614,10 +1614,10 @@ START_TEST(olepicture) /* Test regular 1x1 pixel images of gif, jpg, bmp type */ test_pic(gifimage, sizeof(gifimage), 1, TRUE); test_pic(jpgimage, sizeof(jpgimage), 24, TRUE); - test_pic(bmpimage, sizeof(bmpimage), 1, TRUE); - test_pic(bmpimage4, sizeof(bmpimage4), 4, TRUE); - test_pic(bmpimage8, sizeof(bmpimage8), 8, TRUE); - test_pic(bmpimage24, sizeof(bmpimage24), 24, TRUE); + test_pic(bmpimage, sizeof(bmpimage), 1, FALSE); + test_pic(bmpimage4, sizeof(bmpimage4), 4, FALSE); + test_pic(bmpimage8, sizeof(bmpimage8), 8, FALSE); + test_pic(bmpimage24, sizeof(bmpimage24), 24, FALSE); test_pic(gif4pixel, sizeof(gif4pixel), 4, TRUE); /* FIXME: No PNG support in Windows... */ if (0) test_pic(pngimage, sizeof(pngimage), 32, TRUE);