windowscodecs: Fix 32bppGrayFloat to 8bppGray conversion.
Based on Dmitry Timoshkov's patch. Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d71bc1503b
commit
8bae21302f
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue