From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/converter.c | 44 ++++++++++++++++++++++++++++ dlls/windowscodecs/tests/converter.c | 7 +++++ 2 files changed, 51 insertions(+)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index 04dcb0b9fc5..3607ac25819 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -2048,6 +2048,50 @@ static HRESULT copypixels_to_128bppRGBFloat(struct FormatConverter *This, const free(srcdata); return S_OK; } + case format_48bppRGBHalf: + { + UINT srcstride, srcdatasize; + const USHORT *srcpixel; + const BYTE *srcrow; + float *dstpixel; + BYTE *srcdata; + BYTE *dstrow; + INT x, y; + + if (!prc) + return S_OK; + + srcstride = 6 * prc->Width; + srcdatasize = srcstride * prc->Height; + + srcdata = malloc(srcdatasize); + if (!srcdata) return E_OUTOFMEMORY; + + hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata); + if (SUCCEEDED(hr)) + { + srcrow = srcdata; + dstrow = pbBuffer; + for (y = 0; y < prc->Height; y++) + { + srcpixel = (USHORT *)srcrow; + dstpixel= (float *)dstrow; + for (x = 0; x < prc->Width; x++) + { + *dstpixel++ = float_16_to_32(*srcpixel++); + *dstpixel++ = float_16_to_32(*srcpixel++); + *dstpixel++ = float_16_to_32(*srcpixel++); + *dstpixel++ = 1.0f; + } + srcrow += srcstride; + dstrow += cbStride; + } + } + + free(srcdata); + return S_OK; + } + default: FIXME("Unimplemented conversion path %d.\n", source_format); return WINCODEC_ERR_UNSUPPORTEDOPERATION; diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 2f66df954a5..a94ab9c0324 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -696,6 +696,12 @@ static const float bits_128bppRGBFloat[] = { static const struct bitmap_data testdata_128bppRGBFloat = { &GUID_WICPixelFormat128bppRGBFloat, 128, (const BYTE *)bits_128bppRGBFloat, 3, 2, 96.0, 96.0};
+static const float bits_128bppRGBFloat_2[] = { + 0.0f,0.0f,0.0f,1.0f, 0.0f,1.0f,0.0f,1.0f, 1.0f,0.0f,0.0f,1.0f, + 0.0f,0.0f,1.0f,1.0f, 0.0f,0.205079f,0.0f,1.0f, 0.205079f,0.0f,0.0f,1.0f}; +static const struct bitmap_data testdata_128bppRGBFloat_2 = { + &GUID_WICPixelFormat128bppRGBFloat, 128, (const BYTE *)bits_128bppRGBFloat_2, 3, 2, 96.0, 96.0}; + static const BYTE bits_24bppBGR_2[] = { 0,0,0, 0,255,0, 0,0,255, 255,0,0, 0,125,0, 0,0,125}; @@ -2350,6 +2356,7 @@ START_TEST(converter) test_conversion(&testdata_128bppRGBAFloat_2, &testdata_32bppBGRA_2, "128bppRGBAFloat -> 32bppBGRA", FALSE);
test_conversion(&testdata_48bppRGBHalf, &testdata_32bppBGRA_3, "48bppRGBHalf -> 32bppBGRA", FALSE); + test_conversion(&testdata_48bppRGBHalf, &testdata_128bppRGBFloat_2, "48bppRGBHalf -> 128bppRGBFloat", FALSE);
test_invalid_conversion(); test_default_converter();