Rebase against f4a8ad89d43646a8d109da5747dfb1a92a6d8cd1.

This commit is contained in:
Alistair Leslie-Hughes
2023-07-05 13:05:46 +10:00
parent b97718a0a9
commit 6882ba5e7b
12 changed files with 79 additions and 97 deletions

View File

@@ -1,21 +1,21 @@
From 182a2cbf47a8562a43db6bdc8bd29e0980a9ddcd Mon Sep 17 00:00:00 2001
From a9cd52667f49a57900a08591cd66b40747a12db0 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 21 Apr 2016 14:40:58 +0800
Subject: oleaut32: OleLoadPicture should create a DIB section for a being
loaded bitmap. (v3)
Subject: [PATCH] oleaut32: OleLoadPicture should create a DIB section for a
being loaded bitmap. (v3)
Application in the bug 39474 depends on this (GetObject/bmBits should not be
NULL, otherwise it crashes).
---
dlls/oleaut32/olepicture.c | 65 ++++++++++++++++------------------------
dlls/oleaut32/olepicture.c | 65 +++++++++++++-------------------
dlls/oleaut32/tests/olepicture.c | 2 +-
2 files changed, 27 insertions(+), 40 deletions(-)
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
index bfca22f..1b6fb2c 100644
index 45baa74a439..22a34d6e380 100644
--- a/dlls/oleaut32/olepicture.c
+++ b/dlls/oleaut32/olepicture.c
@@ -999,23 +999,16 @@ static HRESULT OLEPictureImpl_LoadDIB(OLEPictureImpl *This, BYTE *xbuf, ULONG xr
@@ -983,23 +983,16 @@ static HRESULT OLEPictureImpl_LoadDIB(OLEPictureImpl *This, BYTE *xbuf, ULONG xr
{
BITMAPFILEHEADER *bfh = (BITMAPFILEHEADER*)xbuf;
BITMAPINFO *bi = (BITMAPINFO*)(bfh+1);
@@ -27,7 +27,7 @@ index bfca22f..1b6fb2c 100644
- * components which are in both
- */
- hdcref = GetDC(0);
- This->desc.u.bmp.hbitmap = CreateDIBitmap(
- This->desc.bmp.hbitmap = CreateDIBitmap(
- hdcref,
- &(bi->bmiHeader),
- CBM_INIT,
@@ -36,8 +36,8 @@ index bfca22f..1b6fb2c 100644
- DIB_RGB_COLORS
- );
- ReleaseDC(0, hdcref);
+ This->desc.u.bmp.hbitmap = CreateDIBSection(0, bi, DIB_RGB_COLORS, &bits, NULL, 0);
if (This->desc.u.bmp.hbitmap == 0)
+ This->desc.bmp.hbitmap = CreateDIBSection(0, bi, DIB_RGB_COLORS, &bits, NULL, 0);
if (This->desc.bmp.hbitmap == 0)
return E_FAIL;
+
+ GetObjectA(This->desc.u.bmp.hbitmap, sizeof(bmp), &bmp);
@@ -46,7 +46,7 @@ index bfca22f..1b6fb2c 100644
This->desc.picType = PICTYPE_BITMAP;
OLEPictureImpl_SetBitmap(This);
return S_OK;
@@ -1025,10 +1018,9 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
@@ -1009,10 +1002,9 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
{
HRESULT hr;
BITMAPINFOHEADER bih;
@@ -58,7 +58,7 @@ index bfca22f..1b6fb2c 100644
WICRect rc;
IWICBitmapSource *real_source;
UINT x, y;
@@ -1056,34 +1048,28 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
@@ -1040,34 +1032,28 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
stride = 4 * width;
buffersize = stride * height;
@@ -71,8 +71,8 @@ index bfca22f..1b6fb2c 100644
goto end;
}
+ This->desc.u.bmp.hbitmap = CreateDIBSection(0, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void **)&bits, NULL, 0);
+ if (This->desc.u.bmp.hbitmap == 0)
+ This->desc.bmp.hbitmap = CreateDIBSection(0, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void **)&bits, NULL, 0);
+ if (This->desc.bmp.hbitmap == 0)
+ {
+ hr = E_FAIL;
+ goto end;
@@ -87,7 +87,7 @@ index bfca22f..1b6fb2c 100644
- goto end;
-
- hdcref = GetDC(0);
- This->desc.u.bmp.hbitmap = CreateDIBitmap(
- This->desc.bmp.hbitmap = CreateDIBitmap(
- hdcref,
- &bih,
- CBM_INIT,
@@ -95,15 +95,15 @@ index bfca22f..1b6fb2c 100644
- (BITMAPINFO*)&bih,
- DIB_RGB_COLORS);
-
- if (This->desc.u.bmp.hbitmap == 0)
- if (This->desc.bmp.hbitmap == 0)
{
- hr = E_FAIL;
- ReleaseDC(0, hdcref);
+ DeleteObject(This->desc.u.bmp.hbitmap);
+ DeleteObject(This->desc.bmp.hbitmap);
goto end;
}
@@ -1097,23 +1083,25 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
@@ -1081,23 +1067,25 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
if((*pixel & 0x80000000) == 0)
{
has_alpha = TRUE;
@@ -133,7 +133,7 @@ index bfca22f..1b6fb2c 100644
(BITMAPINFO*)&bih,
DIB_RGB_COLORS
);
@@ -1138,12 +1126,11 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
@@ -1122,12 +1110,11 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
DeleteDC(hdcBmp);
DeleteDC(hdcXor);
DeleteDC(hdcMask);
@@ -149,10 +149,10 @@ index bfca22f..1b6fb2c 100644
return hr;
}
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index b716f25..795ee71 100644
index 7b45b690935..fa7e8009cbd 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -240,7 +240,7 @@ test_pic_with_stream(LPSTREAM stream, unsigned int imgsize)
@@ -239,7 +239,7 @@ test_pic_with_stream(LPSTREAM stream, unsigned int imgsize)
{
BITMAP bmp;
GetObjectA(UlongToHandle(handle), sizeof(BITMAP), &bmp);
@@ -162,5 +162,5 @@ index b716f25..795ee71 100644
width = 0;
--
2.9.0
2.40.1

View File

@@ -1,7 +1,7 @@
From edeffac23fae035e8b7910e5e4d97a48d7556220 Mon Sep 17 00:00:00 2001
From e72c3ef9b52c3b5b099907c017206f168cff419f Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 5 Apr 2017 12:03:19 +0800
Subject: oleaut32: Make OleLoadPicture load DIBs using WIC decoder.
Subject: [PATCH] oleaut32: Make OleLoadPicture load DIBs using WIC decoder.
CreateDIBSection doesn't support RLE compressed bitmaps.
@@ -13,10 +13,10 @@ installer.
2 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
index 7d2f9a2eec..96304e0644 100644
index 22a34d6e380..37c3983ed21 100644
--- a/dlls/oleaut32/olepicture.c
+++ b/dlls/oleaut32/olepicture.c
@@ -998,25 +998,6 @@ static HRESULT WINAPI OLEPictureImpl_IsDirty(
@@ -979,25 +979,6 @@ static HRESULT WINAPI OLEPictureImpl_IsDirty(
return E_NOTIMPL;
}
@@ -27,8 +27,8 @@ index 7d2f9a2eec..96304e0644 100644
- void *bits;
- BITMAP bmp;
-
- This->desc.u.bmp.hbitmap = CreateDIBSection(0, bi, DIB_RGB_COLORS, &bits, NULL, 0);
- if (This->desc.u.bmp.hbitmap == 0)
- This->desc.bmp.hbitmap = CreateDIBSection(0, bi, DIB_RGB_COLORS, &bits, NULL, 0);
- if (This->desc.bmp.hbitmap == 0)
- return E_FAIL;
-
- GetObjectA(This->desc.u.bmp.hbitmap, sizeof(bmp), &bmp);
@@ -42,7 +42,7 @@ index 7d2f9a2eec..96304e0644 100644
static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSource *src)
{
HRESULT hr;
@@ -1497,7 +1478,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm)
@@ -1478,7 +1459,7 @@ static HRESULT WINAPI OLEPictureImpl_Load(IPersistStream* iface, IStream *pStm)
hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICJpegDecoder, xbuf, xread);
break;
case BITMAP_FORMAT_BMP: /* Bitmap */
@@ -52,10 +52,10 @@ index 7d2f9a2eec..96304e0644 100644
case BITMAP_FORMAT_PNG: /* PNG */
hr = OLEPictureImpl_LoadWICDecoder(This, &CLSID_WICPngDecoder, xbuf, xread);
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
index 8147bf740c..1e4d55debc 100644
index fa7e8009cbd..a1c3ccf20c3 100644
--- a/dlls/oleaut32/tests/olepicture.c
+++ b/dlls/oleaut32/tests/olepicture.c
@@ -98,7 +98,7 @@ static const unsigned char pngimage[285] = {
@@ -97,7 +97,7 @@ static const unsigned char pngimage[285] = {
0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
@@ -64,7 +64,7 @@ index 8147bf740c..1e4d55debc 100644
static const unsigned char bmpimage[66] = {
0x42,0x4d,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x28,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,
@@ -107,6 +107,15 @@ static const unsigned char bmpimage[66] = {
@@ -106,6 +106,15 @@ static const unsigned char bmpimage[66] = {
0x00,0x00
};
@@ -80,7 +80,7 @@ index 8147bf740c..1e4d55debc 100644
/* 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,
@@ -1461,6 +1470,7 @@ START_TEST(olepicture)
@@ -1492,6 +1501,7 @@ START_TEST(olepicture)
test_pic(gifimage, sizeof(gifimage));
test_pic(jpgimage, sizeof(jpgimage));
test_pic(bmpimage, sizeof(bmpimage));
@@ -89,5 +89,5 @@ index 8147bf740c..1e4d55debc 100644
/* FIXME: No PNG support in Windows... */
if (0) test_pic(pngimage, sizeof(pngimage));
--
2.11.0
2.40.1