mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-09-13 09:17:20 -07:00
Added patch to create DIB section in OleLoadPicture.
This commit is contained in:
parent
686516f539
commit
60387bee03
@ -0,0 +1,140 @@
|
||||
From b4917347dd207d2c02682ca7b16d70838c1c4096 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. (v2)
|
||||
|
||||
Application in the bug 39474 depends on this (GetObject/bmBits should not be
|
||||
NULL, otherwise it crashes).
|
||||
---
|
||||
dlls/oleaut32/olepicture.c | 53 ++++++++++++----------------------------
|
||||
dlls/oleaut32/tests/olepicture.c | 2 +-
|
||||
2 files changed, 17 insertions(+), 38 deletions(-)
|
||||
|
||||
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
|
||||
index 96c109a..d9cab92 100644
|
||||
--- a/dlls/oleaut32/olepicture.c
|
||||
+++ b/dlls/oleaut32/olepicture.c
|
||||
@@ -998,23 +998,16 @@ static HRESULT OLEPictureImpl_LoadDIB(OLEPictureImpl *This, BYTE *xbuf, ULONG xr
|
||||
{
|
||||
BITMAPFILEHEADER *bfh = (BITMAPFILEHEADER*)xbuf;
|
||||
BITMAPINFO *bi = (BITMAPINFO*)(bfh+1);
|
||||
- HDC hdcref;
|
||||
+ void *bits;
|
||||
+ BITMAP bmp;
|
||||
|
||||
- /* Does not matter whether this is a coreheader or not, we only use
|
||||
- * components which are in both
|
||||
- */
|
||||
- hdcref = GetDC(0);
|
||||
- This->desc.u.bmp.hbitmap = CreateDIBitmap(
|
||||
- hdcref,
|
||||
- &(bi->bmiHeader),
|
||||
- CBM_INIT,
|
||||
- xbuf+bfh->bfOffBits,
|
||||
- bi,
|
||||
- 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)
|
||||
return E_FAIL;
|
||||
+
|
||||
+ GetObjectA(This->desc.u.bmp.hbitmap, sizeof(bmp), &bmp);
|
||||
+ memcpy(bits, xbuf + bfh->bfOffBits, bmp.bmHeight * bmp.bmWidthBytes);
|
||||
+
|
||||
This->desc.picType = PICTYPE_BITMAP;
|
||||
OLEPictureImpl_SetBitmap(This);
|
||||
return S_OK;
|
||||
@@ -1024,10 +1017,9 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
|
||||
{
|
||||
HRESULT hr;
|
||||
BITMAPINFOHEADER bih;
|
||||
- HDC hdcref;
|
||||
UINT width, height;
|
||||
UINT stride, buffersize;
|
||||
- LPBYTE bits=NULL;
|
||||
+ BYTE *bits;
|
||||
WICRect rc;
|
||||
IWICBitmapSource *real_source;
|
||||
UINT x, y;
|
||||
@@ -1055,10 +1047,10 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
|
||||
stride = 4 * width;
|
||||
buffersize = stride * height;
|
||||
|
||||
- bits = HeapAlloc(GetProcessHeap(), 0, buffersize);
|
||||
- if (!bits)
|
||||
+ This->desc.u.bmp.hbitmap = CreateDIBSection(0, (BITMAPINFO*)&bih, DIB_RGB_COLORS, (void **)&bits, NULL, 0);
|
||||
+ if (This->desc.u.bmp.hbitmap == 0)
|
||||
{
|
||||
- hr = E_OUTOFMEMORY;
|
||||
+ hr = E_FAIL;
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1068,21 +1060,8 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
|
||||
rc.Height = height;
|
||||
hr = IWICBitmapSource_CopyPixels(real_source, &rc, stride, buffersize, bits);
|
||||
if (FAILED(hr))
|
||||
- goto end;
|
||||
-
|
||||
- hdcref = GetDC(0);
|
||||
- This->desc.u.bmp.hbitmap = CreateDIBitmap(
|
||||
- hdcref,
|
||||
- &bih,
|
||||
- CBM_INIT,
|
||||
- bits,
|
||||
- (BITMAPINFO*)&bih,
|
||||
- DIB_RGB_COLORS);
|
||||
-
|
||||
- if (This->desc.u.bmp.hbitmap == 0)
|
||||
{
|
||||
- hr = E_FAIL;
|
||||
- ReleaseDC(0, hdcref);
|
||||
+ DeleteObject(This->desc.u.bmp.hbitmap);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1105,9 +1084,11 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
|
||||
|
||||
if (has_alpha)
|
||||
{
|
||||
- HDC hdcBmp, hdcXor, hdcMask;
|
||||
+ HDC hdcref, hdcBmp, hdcXor, hdcMask;
|
||||
HBITMAP hbmoldBmp, hbmoldXor, hbmoldMask;
|
||||
|
||||
+ hdcref = GetDC(0);
|
||||
+
|
||||
This->hbmXor = CreateDIBitmap(
|
||||
hdcref,
|
||||
&bih,
|
||||
@@ -1137,12 +1118,10 @@ static HRESULT OLEPictureImpl_LoadWICSource(OLEPictureImpl *This, IWICBitmapSour
|
||||
DeleteDC(hdcBmp);
|
||||
DeleteDC(hdcXor);
|
||||
DeleteDC(hdcMask);
|
||||
+ ReleaseDC(0, hdcref);
|
||||
}
|
||||
|
||||
- ReleaseDC(0, hdcref);
|
||||
-
|
||||
end:
|
||||
- HeapFree(GetProcessHeap(), 0, bits);
|
||||
IWICBitmapSource_Release(real_source);
|
||||
return hr;
|
||||
}
|
||||
diff --git a/dlls/oleaut32/tests/olepicture.c b/dlls/oleaut32/tests/olepicture.c
|
||||
index 0903298..5618d1e 100644
|
||||
--- a/dlls/oleaut32/tests/olepicture.c
|
||||
+++ b/dlls/oleaut32/tests/olepicture.c
|
||||
@@ -221,7 +221,7 @@ test_pic_with_stream(LPSTREAM stream, unsigned int imgsize)
|
||||
{
|
||||
BITMAP bmp;
|
||||
GetObjectA(UlongToHandle(handle), sizeof(BITMAP), &bmp);
|
||||
- todo_wine ok(bmp.bmBits != 0, "not a dib\n");
|
||||
+ ok(bmp.bmBits != 0, "not a dib\n");
|
||||
}
|
||||
|
||||
width = 0;
|
||||
--
|
||||
2.7.1
|
||||
|
1
patches/oleaut32-OleLoadPicture/definition
Normal file
1
patches/oleaut32-OleLoadPicture/definition
Normal file
@ -0,0 +1 @@
|
||||
Fixes: [39474] Create DIB section in OleLoadPicture
|
@ -253,6 +253,7 @@ patch_enable_all ()
|
||||
enable_ole32_HGLOBALStream="$1"
|
||||
enable_oleaut32_CreateTypeLib="$1"
|
||||
enable_oleaut32_OLEPictureImpl_SaveAsFile="$1"
|
||||
enable_oleaut32_OleLoadPicture="$1"
|
||||
enable_oleaut32_OleLoadPictureFile="$1"
|
||||
enable_oleaut32_TKIND_COCLASS="$1"
|
||||
enable_oleaut32_x86_64_Marshaller="$1"
|
||||
@ -932,6 +933,9 @@ patch_enable ()
|
||||
oleaut32-OLEPictureImpl_SaveAsFile)
|
||||
enable_oleaut32_OLEPictureImpl_SaveAsFile="$2"
|
||||
;;
|
||||
oleaut32-OleLoadPicture)
|
||||
enable_oleaut32_OleLoadPicture="$2"
|
||||
;;
|
||||
oleaut32-OleLoadPictureFile)
|
||||
enable_oleaut32_OleLoadPictureFile="$2"
|
||||
;;
|
||||
@ -5554,6 +5558,21 @@ if test "$enable_oleaut32_OLEPictureImpl_SaveAsFile" -eq 1; then
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset oleaut32-OleLoadPicture
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#39474] Create DIB section in OleLoadPicture
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/oleaut32/olepicture.c, dlls/oleaut32/tests/olepicture.c
|
||||
# |
|
||||
if test "$enable_oleaut32_OleLoadPicture" -eq 1; then
|
||||
patch_apply oleaut32-OleLoadPicture/0001-oleaut32-OleLoadPicture-should-create-a-DIB-section-.patch
|
||||
(
|
||||
echo '+ { "Dmitry Timoshkov", "oleaut32: OleLoadPicture should create a DIB section for a being loaded bitmap.", 2 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset oleaut32-OleLoadPictureFile
|
||||
# |
|
||||
# | Modified files:
|
||||
|
Loading…
Reference in New Issue
Block a user