Commit fa36f75c authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

windowscodecs: Add support for converting 32bpp grayscale float to 24bpp BGR format.

parent 1196c3a2
......@@ -969,6 +969,49 @@ static HRESULT copypixels_to_24bppBGR(struct FormatConverter *This, const WICRec
return res;
}
return S_OK;
case format_32bppGrayFloat:
if (prc)
{
BYTE *srcdata;
UINT srcstride, srcdatasize;
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 *gray_float = (float *)src;
BYTE *bgr = dst;
for (x = 0; x < prc->Width; x++)
{
BYTE gray = (BYTE)floorf(to_sRGB_component(gray_float[x]) * 255.0f + 0.51f);
*bgr++ = gray;
*bgr++ = gray;
*bgr++ = gray;
}
src += srcstride;
dst += cbStride;
}
}
HeapFree(GetProcessHeap(), 0, srcdata);
return hr;
}
return S_OK;
default:
FIXME("Unimplemented conversion path!\n");
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
......
......@@ -335,6 +335,12 @@ static const BYTE bits_8bppGray[] = {
static const struct bitmap_data testdata_8bppGray = {
&GUID_WICPixelFormat8bppGray, 8, bits_8bppGray, 4, 2, 96.0, 96.0, &testdata_8bppGray_xp};
static const BYTE bits_24bppBGR_gray[] = {
76,76,76, 220,220,220, 127,127,127, 0,0,0,
247,247,247, 145,145,145, 230,230,230, 255,255,255};
static const struct bitmap_data testdata_24bppBGR_gray = {
&GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR_gray, 4, 2, 96.0, 96.0};
static void test_conversion(const struct bitmap_data *src, const struct bitmap_data *dst, const char *name, BOOL todo)
{
BitmapTestSrc *src_obj;
......@@ -780,6 +786,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_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