windowscodecs: BMP decoder should always return valid image resolution.

This commit is contained in:
Dmitry Timoshkov 2013-01-09 15:46:52 +08:00 committed by Alexandre Julliard
parent 01ab797b64
commit 8d72c2771d
2 changed files with 21 additions and 10 deletions

View file

@ -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,

View file

@ -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);