Commit 8d72c277 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

windowscodecs: BMP decoder should always return valid image resolution.

parent 01ab797b
......@@ -163,22 +163,35 @@ static HRESULT WINAPI BmpFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface
static HRESULT BmpHeader_GetResolution(BITMAPV5HEADER *bih, double *pDpiX, double *pDpiY)
{
LONG resx = 0, resy = 0;
switch (bih->bV5Size)
{
default:
case sizeof(BITMAPCOREHEADER):
*pDpiX = 96.0;
*pDpiY = 96.0;
return S_OK;
break;
case sizeof(BITMAPCOREHEADER2):
case sizeof(BITMAPINFOHEADER):
case sizeof(BITMAPV4HEADER):
case sizeof(BITMAPV5HEADER):
*pDpiX = bih->bV5XPelsPerMeter * 0.0254;
*pDpiY = bih->bV5YPelsPerMeter * 0.0254;
return S_OK;
default:
return E_FAIL;
resx = bih->bV5XPelsPerMeter;
resy = bih->bV5YPelsPerMeter;
break;
}
if (!resx || !resy)
{
*pDpiX = 96.0;
*pDpiY = 96.0;
}
else
{
*pDpiX = resx * 0.0254;
*pDpiY = resy * 0.0254;
}
return S_OK;
}
static HRESULT WINAPI BmpFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
......
......@@ -138,9 +138,7 @@ static void test_decode_24bpp(void)
hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY);
ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr);
todo_wine
ok(dpiX == 96.0, "expected dpiX=96.0, got %f\n", dpiX);
todo_wine
ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY);
hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &guidresult);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment