From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/converter.c | 60 +++++++++++++++++++++++++++- dlls/windowscodecs/regsvr.c | 1 + dlls/windowscodecs/tests/converter.c | 18 ++++++++- 3 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index d72f6b2d8d4..65936e6b30a 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -1688,6 +1688,64 @@ static HRESULT copypixels_to_64bppRGBA(struct FormatConverter *This, const WICRe } }
+static HRESULT copypixels_to_128bppRGBAFloat(struct FormatConverter *This, const WICRect *prc, + UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) +{ + HRESULT hr; + + switch (source_format) + { + case format_24bppBGR: + { + UINT srcstride, srcdatasize; + const BYTE *srcpixel; + const BYTE *srcrow; + float *dstpixel; + BYTE *srcdata; + BYTE *dstrow; + INT x, y; + + if (!prc) + return S_OK; + + srcstride = 3 * 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 = srcrow; + dstpixel= (float *)dstrow; + for (x = 0; x < prc->Width; x++) + { + dstpixel[2] = from_sRGB_component(*srcpixel++ / 255.0f); + dstpixel[1] = from_sRGB_component(*srcpixel++ / 255.0f); + dstpixel[0] = from_sRGB_component(*srcpixel++ / 255.0f); + dstpixel[3] = 1.0f; + + dstpixel += 4; + } + srcrow += srcstride; + dstrow += cbStride; + } + } + + free(srcdata); + return S_OK; + } + default: + FIXME("Unimplemented conversion path %d.\n", source_format); + return WINCODEC_ERR_UNSUPPORTEDOPERATION; + } +} + static HRESULT copypixels_to_128bppRGBFloat(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) { @@ -1777,7 +1835,7 @@ static const struct pixelformatinfo supported_formats[] = { {format_64bppPBGRA, &GUID_WICPixelFormat64bppPBGRA, NULL}, {format_32bppBGR101010, &GUID_WICPixelFormat32bppBGR101010, NULL}, {format_96bppRGBFloat, &GUID_WICPixelFormat96bppRGBFloat, NULL}, - {format_128bppRGBAFloat, &GUID_WICPixelFormat128bppRGBAFloat, NULL}, + {format_128bppRGBAFloat, &GUID_WICPixelFormat128bppRGBAFloat, copypixels_to_128bppRGBAFloat }, {format_128bppPRGBAFloat, &GUID_WICPixelFormat128bppPRGBAFloat, NULL}, {format_128bppRGBFloat, &GUID_WICPixelFormat128bppRGBFloat, copypixels_to_128bppRGBFloat }, {format_32bppR10G10B10A2, &GUID_WICPixelFormat32bppR10G10B10A2, NULL}, diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index 71c9d3b736c..1cba56c058d 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -1684,6 +1684,7 @@ static GUID const * const converter_formats[] = { &GUID_WICPixelFormat64bppRGBA, &GUID_WICPixelFormat32bppCMYK, &GUID_WICPixelFormat128bppRGBFloat, + &GUID_WICPixelFormat128bppRGBAFloat, NULL };
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 3e12326f68e..8122ba51ff5 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -249,7 +249,8 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons } } else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppGrayFloat) - || IsEqualGUID(expect->format, &GUID_WICPixelFormat128bppRGBFloat)) + || IsEqualGUID(expect->format, &GUID_WICPixelFormat128bppRGBFloat) + || IsEqualGUID(expect->format, &GUID_WICPixelFormat128bppRGBAFloat)) { UINT i; const float *a=(const float*)expect->bits, *b=(const float*)converted_bits; @@ -671,6 +672,18 @@ 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 BYTE bits_24bppBGR_2[] = { + 0,0,0, 0,255,0, 0,0,255, + 255,0,0, 0,125,0, 0,0,125}; +static const struct bitmap_data testdata_24bppBGR_2 = { + &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR_2, 3, 2, 96.0, 96.0}; + +static const float bits_128bppRGBAFloat[] = { + 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_128bppRGBAFloat = { + &GUID_WICPixelFormat128bppRGBAFloat, 128, (const BYTE *)bits_128bppRGBAFloat, 3, 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; @@ -796,7 +809,7 @@ static void test_can_convert(void) {WIC_PIXEL_FORMAT(48bppBGRFixedPoint)}, {WIC_PIXEL_FORMAT(96bppRGBFixedPoint)}, {WIC_PIXEL_FORMAT(96bppRGBFloat), TRUE, TRUE, 35, TRUE}, - {WIC_PIXEL_FORMAT(128bppRGBAFloat), TRUE, TRUE, 35}, + {WIC_PIXEL_FORMAT(128bppRGBAFloat), TRUE, TRUE, 34}, {WIC_PIXEL_FORMAT(128bppPRGBAFloat), TRUE, TRUE, 35}, {WIC_PIXEL_FORMAT(128bppRGBFloat), TRUE, TRUE, 34},
@@ -2306,6 +2319,7 @@ START_TEST(converter) test_conversion(&testdata_48bppRGB, &testdata_64bppRGBA_2, "48bppRGB -> 64bppRGBA", FALSE);
test_conversion(&testdata_48bppRGB, &testdata_128bppRGBFloat, "48bppRGB -> 128bppRGBFloat", FALSE); + test_conversion(&testdata_24bppBGR_2, &testdata_128bppRGBAFloat, "24bppBGR -> 128bppRGBAFloat", FALSE);
test_invalid_conversion(); test_default_converter();
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/converter.c | 45 ++++++++++++++++++++++++++++ dlls/windowscodecs/tests/converter.c | 15 +++++++++- 2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index 65936e6b30a..c66329168ca 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -1740,6 +1740,51 @@ static HRESULT copypixels_to_128bppRGBAFloat(struct FormatConverter *This, const free(srcdata); return S_OK; } + case format_32bppBGRA: + { + UINT srcstride, srcdatasize; + const BYTE *srcpixel; + const BYTE *srcrow; + float *dstpixel; + BYTE *srcdata; + BYTE *dstrow; + INT x, y; + + if (!prc) + return S_OK; + + srcstride = 4 * 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 = srcrow; + dstpixel= (float *)dstrow; + for (x = 0; x < prc->Width; x++) + { + dstpixel[2] = from_sRGB_component(*srcpixel++ / 255.0f); + dstpixel[1] = from_sRGB_component(*srcpixel++ / 255.0f); + dstpixel[0] = from_sRGB_component(*srcpixel++ / 255.0f); + dstpixel[3] = *srcpixel++ / 255.0f; + + dstpixel += 4; + } + 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 8122ba51ff5..527d6938a50 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -678,12 +678,24 @@ static const BYTE bits_24bppBGR_2[] = { static const struct bitmap_data testdata_24bppBGR_2 = { &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR_2, 3, 2, 96.0, 96.0};
+static const BYTE bits_32bppBGRA_2[] = { + 0,0,0,0, 0,255,0,128, 0,0,255,255, + 255,0,0,0, 0,125,0,255, 0,0,125,128}; +static const struct bitmap_data testdata_32bppBGRA_2 = { + &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA_2, 3, 2, 96.0, 96.0}; + static const float bits_128bppRGBAFloat[] = { 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_128bppRGBAFloat = { &GUID_WICPixelFormat128bppRGBAFloat, 128, (const BYTE *)bits_128bppRGBAFloat, 3, 2, 96.0, 96.0};
+static const float bits_128bppRGBAFloat_2[] = { + 0.0f,0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f,0.501961f, 1.0f,0.0f,0.0f,1.0f, + 0.0f,0.0f,1.0f,0.0f, 0.0f,0.205079f,0.0f,1.0f, 0.205079f,0.0f,0.0f,0.5019f}; +static const struct bitmap_data testdata_128bppRGBAFloat_2 = { + &GUID_WICPixelFormat128bppRGBAFloat, 128, (const BYTE *)bits_128bppRGBAFloat_2, 3, 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; @@ -809,7 +821,7 @@ static void test_can_convert(void) {WIC_PIXEL_FORMAT(48bppBGRFixedPoint)}, {WIC_PIXEL_FORMAT(96bppRGBFixedPoint)}, {WIC_PIXEL_FORMAT(96bppRGBFloat), TRUE, TRUE, 35, TRUE}, - {WIC_PIXEL_FORMAT(128bppRGBAFloat), TRUE, TRUE, 34}, + {WIC_PIXEL_FORMAT(128bppRGBAFloat), TRUE, TRUE, 33}, {WIC_PIXEL_FORMAT(128bppPRGBAFloat), TRUE, TRUE, 35}, {WIC_PIXEL_FORMAT(128bppRGBFloat), TRUE, TRUE, 34},
@@ -2320,6 +2332,7 @@ START_TEST(converter)
test_conversion(&testdata_48bppRGB, &testdata_128bppRGBFloat, "48bppRGB -> 128bppRGBFloat", FALSE); test_conversion(&testdata_24bppBGR_2, &testdata_128bppRGBAFloat, "24bppBGR -> 128bppRGBAFloat", FALSE); + test_conversion(&testdata_32bppBGRA_2, &testdata_128bppRGBAFloat_2, "32bppBGRA -> 128bppRGBAFloat", FALSE);
test_invalid_conversion(); test_default_converter();
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/converter.c | 49 ++++++++++++++++++++++++++++ dlls/windowscodecs/tests/converter.c | 15 +++++---- 2 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index c66329168ca..6083cdc3eb4 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -878,6 +878,55 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe } } return S_OK; + case format_128bppRGBAFloat: + if (prc) + { + HRESULT res; + INT x, y; + BYTE *srcdata; + UINT srcstride, srcdatasize; + const BYTE *srcrow; + const float *srcpixel; + BYTE *dstrow; + DWORD *dstpixel; + + srcstride = 16 * prc->Width; + srcdatasize = srcstride * prc->Height; + + srcdata = malloc(srcdatasize); + if (!srcdata) return E_OUTOFMEMORY; + + res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata); + + if (SUCCEEDED(res)) + { + srcrow = srcdata; + dstrow = pbBuffer; + for (y = 0; y < prc->Height; y++) + { + srcpixel = (const float *)srcrow; + dstpixel = (DWORD *)dstrow; + for (x = 0; x < prc->Width; x++) + { + BYTE red, green, blue, alpha; + + red = (BYTE)floorf(to_sRGB_component(*srcpixel++) * 255.0f + 0.51f); + green = (BYTE)floorf(to_sRGB_component(*srcpixel++) * 255.0f + 0.51f); + blue = (BYTE)floorf(to_sRGB_component(*srcpixel++) * 255.0f + 0.51f); + alpha = (BYTE)floorf(*srcpixel++ * 255.0f + 0.51f); + + *dstpixel++ = alpha << 24 | red << 16 | green << 8 | blue; + } + srcrow += srcstride; + dstrow += cbStride; + } + } + + free(srcdata); + + return res; + } + return S_OK; default: FIXME("Unimplemented conversion path!\n"); return WINCODEC_ERR_UNSUPPORTEDOPERATION; diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 527d6938a50..6ebe659f154 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -799,13 +799,13 @@ static void test_can_convert(void) {WIC_PIXEL_FORMAT(16bppBGRA5551), TRUE, TRUE, 33, TRUE}, {WIC_PIXEL_FORMAT(24bppBGR), TRUE, TRUE, 27}, {WIC_PIXEL_FORMAT(24bppRGB), TRUE, TRUE, 30}, - {WIC_PIXEL_FORMAT(32bppBGR), TRUE, TRUE, 15}, - {WIC_PIXEL_FORMAT(32bppBGRA), TRUE, TRUE, 15}, - {WIC_PIXEL_FORMAT(32bppPBGRA), TRUE, TRUE, 15}, - {WIC_PIXEL_FORMAT(32bppRGB), TRUE, TRUE, 13, TRUE}, - {WIC_PIXEL_FORMAT(32bppRGBA), TRUE, TRUE, 13, TRUE}, - {WIC_PIXEL_FORMAT(32bppPRGBA), TRUE, TRUE, 13, TRUE}, - {WIC_PIXEL_FORMAT(32bppGrayFloat), TRUE, TRUE, 14}, + {WIC_PIXEL_FORMAT(32bppBGR), TRUE, TRUE, 14}, + {WIC_PIXEL_FORMAT(32bppBGRA), TRUE, TRUE, 14}, + {WIC_PIXEL_FORMAT(32bppPBGRA), TRUE, TRUE, 14}, + {WIC_PIXEL_FORMAT(32bppRGB), TRUE, TRUE, 12, TRUE}, + {WIC_PIXEL_FORMAT(32bppRGBA), TRUE, TRUE, 12, TRUE}, + {WIC_PIXEL_FORMAT(32bppPRGBA), TRUE, TRUE, 12, TRUE}, + {WIC_PIXEL_FORMAT(32bppGrayFloat), TRUE, TRUE, 13},
{WIC_PIXEL_FORMAT(48bppRGB), TRUE, TRUE, 35}, {WIC_PIXEL_FORMAT(48bppBGR), TRUE, TRUE, 35, TRUE}, @@ -2333,6 +2333,7 @@ START_TEST(converter) test_conversion(&testdata_48bppRGB, &testdata_128bppRGBFloat, "48bppRGB -> 128bppRGBFloat", FALSE); test_conversion(&testdata_24bppBGR_2, &testdata_128bppRGBAFloat, "24bppBGR -> 128bppRGBAFloat", FALSE); test_conversion(&testdata_32bppBGRA_2, &testdata_128bppRGBAFloat_2, "32bppBGRA -> 128bppRGBAFloat", FALSE); + test_conversion(&testdata_128bppRGBAFloat_2, &testdata_32bppBGRA_2, "128bppRGBAFloat -> 32bppBGRA", FALSE);
test_invalid_conversion(); test_default_converter();
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/converter.c | 43 ++++++++++++++++++++++++++++ dlls/windowscodecs/regsvr.c | 1 + dlls/windowscodecs/tests/converter.c | 9 +++++- 3 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index 6083cdc3eb4..c1c445a5bd4 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -1890,6 +1890,49 @@ static HRESULT copypixels_to_128bppRGBFloat(struct FormatConverter *This, const free(srcdata); return S_OK; } + case format_96bppRGBFloat: + { + UINT srcstride, srcdatasize; + const float *srcpixel; + const BYTE *srcrow; + float *dstpixel; + BYTE *srcdata; + BYTE *dstrow; + INT x, y; + + if (!prc) + return S_OK; + + srcstride = 12 * 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 = (const float *)srcrow; + dstpixel = (float *)dstrow; + for (x = 0; x < prc->Width; x++) + { + *dstpixel++ = *srcpixel++; + *dstpixel++ = *srcpixel++; + *dstpixel++ = *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/regsvr.c b/dlls/windowscodecs/regsvr.c index 1cba56c058d..def5bac26b1 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -1683,6 +1683,7 @@ static GUID const * const converter_formats[] = { &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat64bppRGBA, &GUID_WICPixelFormat32bppCMYK, + &GUID_WICPixelFormat96bppRGBFloat, &GUID_WICPixelFormat128bppRGBFloat, &GUID_WICPixelFormat128bppRGBAFloat, NULL diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 6ebe659f154..e020c70e160 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -666,6 +666,12 @@ static const WORD bits_64bppRGBA_2[] = { static const struct bitmap_data testdata_64bppRGBA_2 = { &GUID_WICPixelFormat64bppRGBA, 64, (BYTE*)bits_64bppRGBA_2, 3, 2, 96.0, 96.0};
+static const float bits_96bppRGBFloat[] = { + 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f, 0.214039f,0.214053f,0.214039f, + 1.0f,1.0f,1.0f, 0.000012f,0.000012f,0.000012f, 0.0f,0.0f,0.000012f}; +static const struct bitmap_data testdata_96bppRGBFloat = { + &GUID_WICPixelFormat96bppRGBFloat, 96, (const BYTE *)bits_96bppRGBFloat, 3, 2, 96.0, 96.0}; + static const float bits_128bppRGBFloat[] = { 0.0f,0.0f,0.0f,1.0f, 0.0f,1.0f,0.0f,1.0f, 0.214039f,0.214053f,0.214039f,1.0f, 1.0f,1.0f,1.0f,1.0f, 0.000012f,0.000012f,0.000012f,1.0f, 0.0f,0.0f,0.000012f,1.0f,}; @@ -823,7 +829,7 @@ static void test_can_convert(void) {WIC_PIXEL_FORMAT(96bppRGBFloat), TRUE, TRUE, 35, TRUE}, {WIC_PIXEL_FORMAT(128bppRGBAFloat), TRUE, TRUE, 33}, {WIC_PIXEL_FORMAT(128bppPRGBAFloat), TRUE, TRUE, 35}, - {WIC_PIXEL_FORMAT(128bppRGBFloat), TRUE, TRUE, 34}, + {WIC_PIXEL_FORMAT(128bppRGBFloat), TRUE, TRUE, 33},
{WIC_PIXEL_FORMAT(32bppCMYK)},
@@ -2333,6 +2339,7 @@ START_TEST(converter) test_conversion(&testdata_48bppRGB, &testdata_128bppRGBFloat, "48bppRGB -> 128bppRGBFloat", FALSE); test_conversion(&testdata_24bppBGR_2, &testdata_128bppRGBAFloat, "24bppBGR -> 128bppRGBAFloat", FALSE); test_conversion(&testdata_32bppBGRA_2, &testdata_128bppRGBAFloat_2, "32bppBGRA -> 128bppRGBAFloat", FALSE); + test_conversion(&testdata_96bppRGBFloat, &testdata_128bppRGBFloat, "96bppRGBFloat -> 128bppRGBFloat", FALSE); test_conversion(&testdata_128bppRGBAFloat_2, &testdata_32bppBGRA_2, "128bppRGBAFloat -> 32bppBGRA", FALSE);
test_invalid_conversion();
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/converter.c | 48 ++++++++++++++++++++++++++++ dlls/windowscodecs/tests/converter.c | 27 ++++++++++++---- 2 files changed, 68 insertions(+), 7 deletions(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index c1c445a5bd4..526d5c05aca 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -878,6 +878,54 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe } } return S_OK; + case format_96bppRGBFloat: + if (prc) + { + HRESULT res; + INT x, y; + BYTE *srcdata; + UINT srcstride, srcdatasize; + const BYTE *srcrow; + const float *srcpixel; + BYTE *dstrow; + DWORD *dstpixel; + + srcstride = 12 * prc->Width; + srcdatasize = srcstride * prc->Height; + + srcdata = malloc(srcdatasize); + if (!srcdata) return E_OUTOFMEMORY; + + res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata); + + if (SUCCEEDED(res)) + { + srcrow = srcdata; + dstrow = pbBuffer; + for (y = 0; y < prc->Height; y++) + { + srcpixel = (const float *)srcrow; + dstpixel = (DWORD *)dstrow; + for (x = 0; x < prc->Width; x++) + { + BYTE red, green, blue; + + red = (BYTE)floorf(to_sRGB_component(*srcpixel++) * 255.0f + 0.51f); + green = (BYTE)floorf(to_sRGB_component(*srcpixel++) * 255.0f + 0.51f); + blue = (BYTE)floorf(to_sRGB_component(*srcpixel++) * 255.0f + 0.51f); + + *dstpixel++ = 0xff000000 | red << 16 | green << 8 | blue; + } + srcrow += srcstride; + dstrow += cbStride; + } + } + + free(srcdata); + + return res; + } + return S_OK; case format_128bppRGBAFloat: if (prc) { diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index e020c70e160..1cabaac04d8 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -672,6 +672,18 @@ static const float bits_96bppRGBFloat[] = { static const struct bitmap_data testdata_96bppRGBFloat = { &GUID_WICPixelFormat96bppRGBFloat, 96, (const BYTE *)bits_96bppRGBFloat, 3, 2, 96.0, 96.0};
+static const float bits_96bppRGBFloat_2[] = { + 0.0f,0.0f,0.0f, 0.0f,1.0f,0.0f, 1.0f,0.0f,0.0f, + 0.0f,0.0f,1.0f, 0.0f,0.205079f,0.0f, 0.205079f,0.0f,0.0f}; +static const struct bitmap_data testdata_96bppRGBFloat_2 = { + &GUID_WICPixelFormat96bppRGBFloat, 96, (const BYTE *)bits_96bppRGBFloat_2, 3, 2, 96.0, 96.0}; + +static const BYTE bits_32bppBGRA_3[] = { + 0,0,0,255, 0,255,0,255, 0,0,255,255, + 255,0,0,255, 0,125,0,255, 0,0,125,255}; +static const struct bitmap_data testdata_32bppBGRA_3 = { + &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA_3, 3, 2, 96.0, 96.0}; + static const float bits_128bppRGBFloat[] = { 0.0f,0.0f,0.0f,1.0f, 0.0f,1.0f,0.0f,1.0f, 0.214039f,0.214053f,0.214039f,1.0f, 1.0f,1.0f,1.0f,1.0f, 0.000012f,0.000012f,0.000012f,1.0f, 0.0f,0.0f,0.000012f,1.0f,}; @@ -805,13 +817,13 @@ static void test_can_convert(void) {WIC_PIXEL_FORMAT(16bppBGRA5551), TRUE, TRUE, 33, TRUE}, {WIC_PIXEL_FORMAT(24bppBGR), TRUE, TRUE, 27}, {WIC_PIXEL_FORMAT(24bppRGB), TRUE, TRUE, 30}, - {WIC_PIXEL_FORMAT(32bppBGR), TRUE, TRUE, 14}, - {WIC_PIXEL_FORMAT(32bppBGRA), TRUE, TRUE, 14}, - {WIC_PIXEL_FORMAT(32bppPBGRA), TRUE, TRUE, 14}, - {WIC_PIXEL_FORMAT(32bppRGB), TRUE, TRUE, 12, TRUE}, - {WIC_PIXEL_FORMAT(32bppRGBA), TRUE, TRUE, 12, TRUE}, - {WIC_PIXEL_FORMAT(32bppPRGBA), TRUE, TRUE, 12, TRUE}, - {WIC_PIXEL_FORMAT(32bppGrayFloat), TRUE, TRUE, 13}, + {WIC_PIXEL_FORMAT(32bppBGR), TRUE, TRUE, 13}, + {WIC_PIXEL_FORMAT(32bppBGRA), TRUE, TRUE, 13}, + {WIC_PIXEL_FORMAT(32bppPBGRA), TRUE, TRUE, 13}, + {WIC_PIXEL_FORMAT(32bppRGB), TRUE, TRUE, 11, TRUE}, + {WIC_PIXEL_FORMAT(32bppRGBA), TRUE, TRUE, 11, TRUE}, + {WIC_PIXEL_FORMAT(32bppPRGBA), TRUE, TRUE, 11, TRUE}, + {WIC_PIXEL_FORMAT(32bppGrayFloat), TRUE, TRUE, 12},
{WIC_PIXEL_FORMAT(48bppRGB), TRUE, TRUE, 35}, {WIC_PIXEL_FORMAT(48bppBGR), TRUE, TRUE, 35, TRUE}, @@ -2340,6 +2352,7 @@ START_TEST(converter) test_conversion(&testdata_24bppBGR_2, &testdata_128bppRGBAFloat, "24bppBGR -> 128bppRGBAFloat", FALSE); test_conversion(&testdata_32bppBGRA_2, &testdata_128bppRGBAFloat_2, "32bppBGRA -> 128bppRGBAFloat", FALSE); test_conversion(&testdata_96bppRGBFloat, &testdata_128bppRGBFloat, "96bppRGBFloat -> 128bppRGBFloat", FALSE); + test_conversion(&testdata_96bppRGBFloat_2, &testdata_32bppBGRA_3, "96bppRGBFloat -> 32bppBGRA", FALSE); test_conversion(&testdata_128bppRGBAFloat_2, &testdata_32bppBGRA_2, "128bppRGBAFloat -> 32bppBGRA", FALSE);
test_invalid_conversion();
This may have actually broken the GDI+ tests by causing a format conversion to succeed?
We have a similar test disabled for RGB, I think it'd be fine to disable it for RGBA too: https://gitlab.winehq.org/wine/wine/-/blob/b8be01a16394346e418a7efa4447f548b...