Commit 8bae2130 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

windowscodecs: Fix 32bppGrayFloat to 8bppGray conversion.

Based on Dmitry Timoshkov's patch. Signed-off-by: 's avatarVincent Povirk <vincent@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent d71bc150
......@@ -1149,6 +1149,43 @@ static HRESULT copypixels_to_8bppGray(struct FormatConverter *This, const WICRec
return S_OK;
}
if (source_format == format_32bppGrayFloat)
{
hr = S_OK;
if (prc)
{
srcstride = 4 * prc->Width;
srcdatasize = srcstride * prc->Height;
srcdata = HeapAlloc(GetProcessHeap(), 0, srcdatasize);
if (!srcdata) return E_OUTOFMEMORY;
hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
if (SUCCEEDED(hr))
{
INT x, y;
BYTE *src = srcdata, *dst = pbBuffer;
for (y=0; y < prc->Height; y++)
{
float *srcpixel = (float*)src;
BYTE *dstpixel = dst;
for (x=0; x < prc->Width; x++)
*dstpixel++ = (BYTE)floorf(to_sRGB_component(*srcpixel++) * 255.0f + 0.51f);
src += srcstride;
dst += cbStride;
}
}
HeapFree(GetProcessHeap(), 0, srcdata);
}
return hr;
}
srcstride = 3 * prc->Width;
srcdatasize = srcstride * prc->Height;
......
......@@ -880,6 +880,7 @@ START_TEST(converter)
test_conversion(&testdata_24bppBGR, &testdata_8bppGray, "24bppBGR -> 8bppGray", FALSE);
test_conversion(&testdata_32bppBGR, &testdata_8bppGray, "32bppBGR -> 8bppGray", FALSE);
test_conversion(&testdata_32bppGrayFloat, &testdata_24bppBGR_gray, "32bppGrayFloat -> 24bppBGR gray", FALSE);
test_conversion(&testdata_32bppGrayFloat, &testdata_8bppGray, "32bppGrayFloat -> 8bppGray", FALSE);
test_invalid_conversion();
test_default_converter();
......
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