d3dx9-32bpp_Alpha_Channel: Restore mistakenly deleted patch.

Only the tests were upstreamed, and they do not pass without this patch.
This commit is contained in:
Zebediah Figura 2019-04-05 18:46:30 -05:00
parent 0e7183639d
commit 4ea094eddb
3 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From b2bae3c7d8f8b6dfc7587b7a7a3147f5650096a7 Mon Sep 17 00:00:00 2001
From: Christian Costa <titan.costa@gmail.com>
Date: Sun, 30 Jul 2017 23:50:18 +0200
Subject: d3dx9: Return D3DFMT_A8R8G8B8 in D3DXGetImageInfoFromFileInMemory for
32 bpp BMP with alpha.
---
dlls/d3dx9_36/surface.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c
index c82c22289..abb1c0e5c 100644
--- a/dlls/d3dx9_36/surface.c
+++ b/dlls/d3dx9_36/surface.c
@@ -954,6 +954,24 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
}
}
+ /* For 32 bpp BMP, windowscodecs.dll never returns a format with alpha while
+ * d3dx9_xx.dll returns one if at least 1 pixel has a non zero alpha component */
+ if (SUCCEEDED(hr) && (info->Format == D3DFMT_X8R8G8B8) && (info->ImageFileFormat == D3DXIFF_BMP)) {
+ DWORD size = sizeof(DWORD) * info->Width * info->Height;
+ BYTE *buffer = HeapAlloc(GetProcessHeap(), 0, size);
+ hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, sizeof(DWORD) * info->Width, size, buffer);
+ if (SUCCEEDED(hr)) {
+ DWORD i;
+ for (i = 0; i < info->Width * info->Height; i++) {
+ if (buffer[i*4+3]) {
+ info->Format = D3DFMT_A8R8G8B8;
+ break;
+ }
+ }
+ }
+ HeapFree(GetProcessHeap(), 0, buffer);
+ }
+
if (frame)
IWICBitmapFrameDecode_Release(frame);
--
2.20.1

View File

@ -0,0 +1 @@
Fixes: Return D3DFMT_A8R8G8B8 in D3DXGetImageInfoFromFileInMemory for 32 bpp BMP with alpha

View File

@ -106,6 +106,7 @@ patch_enable_all ()
enable_d3d11_Deferred_Context="$1"
enable_d3d9_DesktopWindow="$1"
enable_d3d9_Tests="$1"
enable_d3dx9_32bpp_Alpha_Channel="$1"
enable_d3dx9_36_BumpLuminance="$1"
enable_d3dx9_36_CloneEffect="$1"
enable_d3dx9_36_D3DXDisassembleShader="$1"
@ -459,6 +460,9 @@ patch_enable ()
d3d9-Tests)
enable_d3d9_Tests="$2"
;;
d3dx9-32bpp_Alpha_Channel)
enable_d3dx9_32bpp_Alpha_Channel="$2"
;;
d3dx9_36-BumpLuminance)
enable_d3dx9_36_BumpLuminance="$2"
;;
@ -2752,6 +2756,18 @@ if test "$enable_d3d9_Tests" -eq 1; then
) >> "$patchlist"
fi
# Patchset d3dx9-32bpp_Alpha_Channel
# |
# | Modified files:
# | * dlls/d3dx9_36/surface.c
# |
if test "$enable_d3dx9_32bpp_Alpha_Channel" -eq 1; then
patch_apply d3dx9-32bpp_Alpha_Channel/0001-d3dx9-Return-D3DFMT_A8R8G8B8-in-D3DXGetImageInfoFrom.patch
(
printf '%s\n' '+ { "Christian Costa", "d3dx9: Return D3DFMT_A8R8G8B8 in D3DXGetImageInfoFromFileInMemory for 32 bpp BMP with alpha.", 1 },';
) >> "$patchlist"
fi
# Patchset d3dx9_36-BumpLuminance
# |
# | Modified files: