From: Daniel Lehman dlehman25@gmail.com
--- dlls/oleaut32/tests/olepicture.c | 40 +++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 14 deletions(-)
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c index 07d9ba98f1b..9e80e048ac7 100644 --- a/dlls/oleaut32/tests/olepicture.c +++ b/dlls/oleaut32/tests/olepicture.c @@ -201,7 +201,7 @@ typedef struct NoStatStreamImpl static IStream* NoStatStream_Construct(HGLOBAL hGlobal);
static void -test_pic_with_stream(LPSTREAM stream, unsigned int imgsize) +test_pic_with_stream(LPSTREAM stream, unsigned int imgsize, int bpp, BOOL todo) { IPicture* pic = NULL; HRESULT hres; @@ -238,8 +238,20 @@ test_pic_with_stream(LPSTREAM stream, unsigned int imgsize) if (handle) { BITMAP bmp; + DIBSECTION dib; + GetObjectA(UlongToHandle(handle), sizeof(BITMAP), &bmp); - todo_wine ok(bmp.bmBits != 0, "not a dib\n"); + todo_wine_if(todo) { + ok(bmp.bmBitsPixel == bpp, "expected %d, got %d\n", bpp, bmp.bmBitsPixel); + ok(bmp.bmBits != 0, "not a dib\n"); + } + + GetObjectA(UlongToHandle(handle), sizeof(DIBSECTION), &dib); + todo_wine_if(todo) { + ok(dib.dsBm.bmBitsPixel == bpp, "expected %d, got %d\n", bpp, dib.dsBm.bmBitsPixel); + ok(dib.dsBm.bmBits != 0, "not a dib\n"); + ok(dib.dsBmih.biBitCount == bpp, "expected %d, got %d\n", bpp, dib.dsBmih.biBitCount); + } }
width = 0; @@ -273,7 +285,7 @@ test_pic_with_stream(LPSTREAM stream, unsigned int imgsize) }
static void -test_pic(const unsigned char *imgdata, unsigned int imgsize) +test_pic(const unsigned char *imgdata, unsigned int imgsize, int bpp, BOOL todo) { LPSTREAM stream; HGLOBAL hglob; @@ -296,14 +308,14 @@ test_pic(const unsigned char *imgdata, unsigned int imgsize) memset(&seekto,0,sizeof(seekto)); hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1); ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08lx\n", hres); - test_pic_with_stream(stream, imgsize); - + test_pic_with_stream(stream, imgsize, bpp, todo); + IStream_Release(stream);
/* again with Non Statable and Non Seekable stream */ stream = NoStatStream_Construct(hglob); hglob = 0; /* Non-statable impl always deletes on release */ - test_pic_with_stream(stream, 0); + test_pic_with_stream(stream, 0, bpp, todo);
IStream_Release(stream); for (i = 1; i <= 8; i++) { @@ -327,14 +339,14 @@ test_pic(const unsigned char *imgdata, unsigned int imgsize) memset(&seekto,0,sizeof(seekto)); hres = IStream_Seek(stream,seekto,SEEK_CUR,&newpos1); ok (hres == S_OK, "istream seek failed? doubt it... hres 0x%08lx\n", hres); - test_pic_with_stream(stream, imgsize); - + test_pic_with_stream(stream, imgsize, bpp, todo); + IStream_Release(stream);
/* again with Non Statable and Non Seekable stream */ stream = NoStatStream_Construct(hglob); hglob = 0; /* Non-statable impl always deletes on release */ - test_pic_with_stream(stream, 0); + test_pic_with_stream(stream, 0, bpp, todo);
IStream_Release(stream); } @@ -1508,12 +1520,12 @@ START_TEST(olepicture) }
/* Test regular 1x1 pixel images of gif, jpg, bmp type */ - test_pic(gifimage, sizeof(gifimage)); - test_pic(jpgimage, sizeof(jpgimage)); - test_pic(bmpimage, sizeof(bmpimage)); - test_pic(gif4pixel, sizeof(gif4pixel)); + test_pic(gifimage, sizeof(gifimage), 1, TRUE); + test_pic(jpgimage, sizeof(jpgimage), 24, TRUE); + test_pic(bmpimage, sizeof(bmpimage), 1, TRUE); + test_pic(gif4pixel, sizeof(gif4pixel), 4, TRUE); /* FIXME: No PNG support in Windows... */ - if (0) test_pic(pngimage, sizeof(pngimage)); + if (0) test_pic(pngimage, sizeof(pngimage), 32, TRUE); test_empty_image(); test_empty_image_2(); if (pOleLoadPictureEx)
From: Daniel Lehman dlehman25@gmail.com
--- dlls/oleaut32/tests/olepicture.c | 95 ++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+)
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c index 9e80e048ac7..0fb308f5d2f 100644 --- a/dlls/oleaut32/tests/olepicture.c +++ b/dlls/oleaut32/tests/olepicture.c @@ -106,6 +106,98 @@ static const unsigned char bmpimage[66] = { 0x00,0x00 };
+/* 1x1 pixel 4-bit bmp */ +static const unsigned char bmpimage4[122] = { +0x42,0x4d,0x7a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x00,0x00,0x00,0x28,0x00, +0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0x00, +0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80, +0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x80, +0x00,0x00,0x80,0x80,0x80,0x00,0xc0,0xc0,0xc0,0x00,0x00,0x00,0xff,0x00,0x00,0xff, +0x00,0x00,0x00,0xff,0xff,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0xff,0xff, +0x00,0x00,0xff,0xff,0xff,0x00,0xf0,0x00,0x00,0x00, +}; + +/* 1x1 pixel 8-bit bmp */ +static const unsigned char bmpimage8[1082] = { +0x42,0x4d,0x3a,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x04,0x00,0x00,0x28,0x00, +0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0x00, +0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80, +0x00,0x00,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x80, +0x00,0x00,0xc0,0xc0,0xc0,0x00,0xc0,0xdc,0xc0,0x00,0xf0,0xca,0xa6,0x00,0x00,0x20, +0x40,0x00,0x00,0x20,0x60,0x00,0x00,0x20,0x80,0x00,0x00,0x20,0xa0,0x00,0x00,0x20, +0xc0,0x00,0x00,0x20,0xe0,0x00,0x00,0x40,0x00,0x00,0x00,0x40,0x20,0x00,0x00,0x40, +0x40,0x00,0x00,0x40,0x60,0x00,0x00,0x40,0x80,0x00,0x00,0x40,0xa0,0x00,0x00,0x40, +0xc0,0x00,0x00,0x40,0xe0,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x20,0x00,0x00,0x60, +0x40,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x80,0x00,0x00,0x60,0xa0,0x00,0x00,0x60, +0xc0,0x00,0x00,0x60,0xe0,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x20,0x00,0x00,0x80, +0x40,0x00,0x00,0x80,0x60,0x00,0x00,0x80,0x80,0x00,0x00,0x80,0xa0,0x00,0x00,0x80, +0xc0,0x00,0x00,0x80,0xe0,0x00,0x00,0xa0,0x00,0x00,0x00,0xa0,0x20,0x00,0x00,0xa0, +0x40,0x00,0x00,0xa0,0x60,0x00,0x00,0xa0,0x80,0x00,0x00,0xa0,0xa0,0x00,0x00,0xa0, +0xc0,0x00,0x00,0xa0,0xe0,0x00,0x00,0xc0,0x00,0x00,0x00,0xc0,0x20,0x00,0x00,0xc0, +0x40,0x00,0x00,0xc0,0x60,0x00,0x00,0xc0,0x80,0x00,0x00,0xc0,0xa0,0x00,0x00,0xc0, +0xc0,0x00,0x00,0xc0,0xe0,0x00,0x00,0xe0,0x00,0x00,0x00,0xe0,0x20,0x00,0x00,0xe0, +0x40,0x00,0x00,0xe0,0x60,0x00,0x00,0xe0,0x80,0x00,0x00,0xe0,0xa0,0x00,0x00,0xe0, +0xc0,0x00,0x00,0xe0,0xe0,0x00,0x40,0x00,0x00,0x00,0x40,0x00,0x20,0x00,0x40,0x00, +0x40,0x00,0x40,0x00,0x60,0x00,0x40,0x00,0x80,0x00,0x40,0x00,0xa0,0x00,0x40,0x00, +0xc0,0x00,0x40,0x00,0xe0,0x00,0x40,0x20,0x00,0x00,0x40,0x20,0x20,0x00,0x40,0x20, +0x40,0x00,0x40,0x20,0x60,0x00,0x40,0x20,0x80,0x00,0x40,0x20,0xa0,0x00,0x40,0x20, +0xc0,0x00,0x40,0x20,0xe0,0x00,0x40,0x40,0x00,0x00,0x40,0x40,0x20,0x00,0x40,0x40, +0x40,0x00,0x40,0x40,0x60,0x00,0x40,0x40,0x80,0x00,0x40,0x40,0xa0,0x00,0x40,0x40, +0xc0,0x00,0x40,0x40,0xe0,0x00,0x40,0x60,0x00,0x00,0x40,0x60,0x20,0x00,0x40,0x60, +0x40,0x00,0x40,0x60,0x60,0x00,0x40,0x60,0x80,0x00,0x40,0x60,0xa0,0x00,0x40,0x60, +0xc0,0x00,0x40,0x60,0xe0,0x00,0x40,0x80,0x00,0x00,0x40,0x80,0x20,0x00,0x40,0x80, +0x40,0x00,0x40,0x80,0x60,0x00,0x40,0x80,0x80,0x00,0x40,0x80,0xa0,0x00,0x40,0x80, +0xc0,0x00,0x40,0x80,0xe0,0x00,0x40,0xa0,0x00,0x00,0x40,0xa0,0x20,0x00,0x40,0xa0, +0x40,0x00,0x40,0xa0,0x60,0x00,0x40,0xa0,0x80,0x00,0x40,0xa0,0xa0,0x00,0x40,0xa0, +0xc0,0x00,0x40,0xa0,0xe0,0x00,0x40,0xc0,0x00,0x00,0x40,0xc0,0x20,0x00,0x40,0xc0, +0x40,0x00,0x40,0xc0,0x60,0x00,0x40,0xc0,0x80,0x00,0x40,0xc0,0xa0,0x00,0x40,0xc0, +0xc0,0x00,0x40,0xc0,0xe0,0x00,0x40,0xe0,0x00,0x00,0x40,0xe0,0x20,0x00,0x40,0xe0, +0x40,0x00,0x40,0xe0,0x60,0x00,0x40,0xe0,0x80,0x00,0x40,0xe0,0xa0,0x00,0x40,0xe0, +0xc0,0x00,0x40,0xe0,0xe0,0x00,0x80,0x00,0x00,0x00,0x80,0x00,0x20,0x00,0x80,0x00, +0x40,0x00,0x80,0x00,0x60,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xa0,0x00,0x80,0x00, +0xc0,0x00,0x80,0x00,0xe0,0x00,0x80,0x20,0x00,0x00,0x80,0x20,0x20,0x00,0x80,0x20, +0x40,0x00,0x80,0x20,0x60,0x00,0x80,0x20,0x80,0x00,0x80,0x20,0xa0,0x00,0x80,0x20, +0xc0,0x00,0x80,0x20,0xe0,0x00,0x80,0x40,0x00,0x00,0x80,0x40,0x20,0x00,0x80,0x40, +0x40,0x00,0x80,0x40,0x60,0x00,0x80,0x40,0x80,0x00,0x80,0x40,0xa0,0x00,0x80,0x40, +0xc0,0x00,0x80,0x40,0xe0,0x00,0x80,0x60,0x00,0x00,0x80,0x60,0x20,0x00,0x80,0x60, +0x40,0x00,0x80,0x60,0x60,0x00,0x80,0x60,0x80,0x00,0x80,0x60,0xa0,0x00,0x80,0x60, +0xc0,0x00,0x80,0x60,0xe0,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x20,0x00,0x80,0x80, +0x40,0x00,0x80,0x80,0x60,0x00,0x80,0x80,0x80,0x00,0x80,0x80,0xa0,0x00,0x80,0x80, +0xc0,0x00,0x80,0x80,0xe0,0x00,0x80,0xa0,0x00,0x00,0x80,0xa0,0x20,0x00,0x80,0xa0, +0x40,0x00,0x80,0xa0,0x60,0x00,0x80,0xa0,0x80,0x00,0x80,0xa0,0xa0,0x00,0x80,0xa0, +0xc0,0x00,0x80,0xa0,0xe0,0x00,0x80,0xc0,0x00,0x00,0x80,0xc0,0x20,0x00,0x80,0xc0, +0x40,0x00,0x80,0xc0,0x60,0x00,0x80,0xc0,0x80,0x00,0x80,0xc0,0xa0,0x00,0x80,0xc0, +0xc0,0x00,0x80,0xc0,0xe0,0x00,0x80,0xe0,0x00,0x00,0x80,0xe0,0x20,0x00,0x80,0xe0, +0x40,0x00,0x80,0xe0,0x60,0x00,0x80,0xe0,0x80,0x00,0x80,0xe0,0xa0,0x00,0x80,0xe0, +0xc0,0x00,0x80,0xe0,0xe0,0x00,0xc0,0x00,0x00,0x00,0xc0,0x00,0x20,0x00,0xc0,0x00, +0x40,0x00,0xc0,0x00,0x60,0x00,0xc0,0x00,0x80,0x00,0xc0,0x00,0xa0,0x00,0xc0,0x00, +0xc0,0x00,0xc0,0x00,0xe0,0x00,0xc0,0x20,0x00,0x00,0xc0,0x20,0x20,0x00,0xc0,0x20, +0x40,0x00,0xc0,0x20,0x60,0x00,0xc0,0x20,0x80,0x00,0xc0,0x20,0xa0,0x00,0xc0,0x20, +0xc0,0x00,0xc0,0x20,0xe0,0x00,0xc0,0x40,0x00,0x00,0xc0,0x40,0x20,0x00,0xc0,0x40, +0x40,0x00,0xc0,0x40,0x60,0x00,0xc0,0x40,0x80,0x00,0xc0,0x40,0xa0,0x00,0xc0,0x40, +0xc0,0x00,0xc0,0x40,0xe0,0x00,0xc0,0x60,0x00,0x00,0xc0,0x60,0x20,0x00,0xc0,0x60, +0x40,0x00,0xc0,0x60,0x60,0x00,0xc0,0x60,0x80,0x00,0xc0,0x60,0xa0,0x00,0xc0,0x60, +0xc0,0x00,0xc0,0x60,0xe0,0x00,0xc0,0x80,0x00,0x00,0xc0,0x80,0x20,0x00,0xc0,0x80, +0x40,0x00,0xc0,0x80,0x60,0x00,0xc0,0x80,0x80,0x00,0xc0,0x80,0xa0,0x00,0xc0,0x80, +0xc0,0x00,0xc0,0x80,0xe0,0x00,0xc0,0xa0,0x00,0x00,0xc0,0xa0,0x20,0x00,0xc0,0xa0, +0x40,0x00,0xc0,0xa0,0x60,0x00,0xc0,0xa0,0x80,0x00,0xc0,0xa0,0xa0,0x00,0xc0,0xa0, +0xc0,0x00,0xc0,0xa0,0xe0,0x00,0xc0,0xc0,0x00,0x00,0xc0,0xc0,0x20,0x00,0xc0,0xc0, +0x40,0x00,0xc0,0xc0,0x60,0x00,0xc0,0xc0,0x80,0x00,0xc0,0xc0,0xa0,0x00,0xf0,0xfb, +0xff,0x00,0xa4,0xa0,0xa0,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0xff,0x00,0x00,0xff, +0x00,0x00,0x00,0xff,0xff,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0xff,0x00,0xff,0xff, +0x00,0x00,0xff,0xff,0xff,0x00,0xff,0x00,0x00,0x00, +}; + +/* 1x1 pixel 24-bit bmp */ +static const unsigned char bmpimage24[58] = { +0x42,0x4d,0x3a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, +0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x18,0x00,0x00,0x00, +0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x00, +}; + /* 2x2 pixel gif */ static const unsigned char gif4pixel[42] = { 0x47,0x49,0x46,0x38,0x37,0x61,0x02,0x00,0x02,0x00,0xa1,0x00,0x00,0x00,0x00,0x00, @@ -1523,6 +1615,9 @@ START_TEST(olepicture) 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(gif4pixel, sizeof(gif4pixel), 4, TRUE); /* FIXME: No PNG support in Windows... */ if (0) test_pic(pngimage, sizeof(pngimage), 32, TRUE);
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);
This is going to create a regression like in https://github.com/wine-staging/wine-staging/tree/master/patches/oleaut32-Ol...
On Fri Mar 22 14:06:50 2024 +0000, Dmitry Timoshkov wrote:
This is going to create a regression like in https://github.com/wine-staging/wine-staging/tree/master/patches/oleaut32-Ol...
ah, i didn't see those patches
This merge request was closed by Daniel Lehman.
On Fri Mar 22 14:06:50 2024 +0000, Daniel Lehman wrote:
ah, i didn't see those patches
@dmitry do you plan to submit them? is it ok if i submit them, maybe with changes?
On Fri May 3 05:09:36 2024 +0000, Daniel Lehman wrote:
@dmitry do you plan to submit them? is it ok if i submit them, maybe with changes?
Thanks for asking. Sure.