diff --git a/patches/d3dx9-32bpp_Alpha_Channel/0001-d3dx9-Return-D3DFMT_A8R8G8B8-in-D3DXGetImageInfoFrom.patch b/patches/d3dx9-32bpp_Alpha_Channel/0001-d3dx9-Return-D3DFMT_A8R8G8B8-in-D3DXGetImageInfoFrom.patch new file mode 100644 index 00000000..b0d8a2cc --- /dev/null +++ b/patches/d3dx9-32bpp_Alpha_Channel/0001-d3dx9-Return-D3DFMT_A8R8G8B8-in-D3DXGetImageInfoFrom.patch @@ -0,0 +1,42 @@ +From b2bae3c7d8f8b6dfc7587b7a7a3147f5650096a7 Mon Sep 17 00:00:00 2001 +From: Christian Costa +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 + diff --git a/patches/d3dx9-32bpp_Alpha_Channel/definition b/patches/d3dx9-32bpp_Alpha_Channel/definition new file mode 100644 index 00000000..875f5553 --- /dev/null +++ b/patches/d3dx9-32bpp_Alpha_Channel/definition @@ -0,0 +1 @@ +Fixes: Return D3DFMT_A8R8G8B8 in D3DXGetImageInfoFromFileInMemory for 32 bpp BMP with alpha diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 388d1a6b..a03312f2 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -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: