d3dx9: Return D3DFMT_A8R8G8B8 in D3DXGetImageInfoFromFileInMemory for 32 bpp BMP with alpha.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48563
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 8f6c832b31
)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
parent
00fb915af4
commit
e4976c0c98
|
@ -887,6 +887,41 @@ static BOOL convert_dib_to_bmp(const void **data, unsigned int *size)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* windowscodecs always returns xRGB, but we should return ARGB if and only if
|
||||||
|
* at least one pixel has a non-zero alpha component. */
|
||||||
|
static BOOL image_is_argb(IWICBitmapFrameDecode *frame, const D3DXIMAGE_INFO *info)
|
||||||
|
{
|
||||||
|
unsigned int size, i;
|
||||||
|
BYTE *buffer;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
if (info->Format != D3DFMT_X8R8G8B8 || info->ImageFileFormat != D3DXIFF_BMP)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
size = info->Width * info->Height * 4;
|
||||||
|
if (!(buffer = malloc(size)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (FAILED(hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, info->Width * 4, size, buffer)))
|
||||||
|
{
|
||||||
|
ERR("Failed to copy pixels, hr %#x.\n", hr);
|
||||||
|
free(buffer);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < info->Width * info->Height; ++i)
|
||||||
|
{
|
||||||
|
if (buffer[i * 4 + 3])
|
||||||
|
{
|
||||||
|
free(buffer);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
* D3DXGetImageInfoFromFileInMemory
|
* D3DXGetImageInfoFromFileInMemory
|
||||||
*
|
*
|
||||||
|
@ -1006,6 +1041,9 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr) && image_is_argb(frame, info))
|
||||||
|
info->Format = D3DFMT_A8R8G8B8;
|
||||||
|
|
||||||
if (frame)
|
if (frame)
|
||||||
IWICBitmapFrameDecode_Release(frame);
|
IWICBitmapFrameDecode_Release(frame);
|
||||||
|
|
||||||
|
|
|
@ -698,7 +698,7 @@ static void test_D3DXGetImageInfo(void)
|
||||||
ok(info.Format == D3DFMT_X8R8G8B8, "Got unexpected format %u.\n", info.Format);
|
ok(info.Format == D3DFMT_X8R8G8B8, "Got unexpected format %u.\n", info.Format);
|
||||||
hr = D3DXGetImageInfoFromFileInMemory(bmp_32bpp_argb, sizeof(bmp_32bpp_argb), &info);
|
hr = D3DXGetImageInfoFromFileInMemory(bmp_32bpp_argb, sizeof(bmp_32bpp_argb), &info);
|
||||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||||
todo_wine ok(info.Format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", info.Format);
|
ok(info.Format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", info.Format);
|
||||||
|
|
||||||
/* Grayscale PNG */
|
/* Grayscale PNG */
|
||||||
hr = D3DXGetImageInfoFromFileInMemory(png_grayscale, sizeof(png_grayscale), &info);
|
hr = D3DXGetImageInfoFromFileInMemory(png_grayscale, sizeof(png_grayscale), &info);
|
||||||
|
|
Loading…
Reference in New Issue