diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index f8f47904..9c67b339 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -57,7 +57,7 @@ upstream_commit() # Show version information version() { - echo "Wine Staging 1.9.5" + echo "Wine Staging 1.9.6 (unreleased)" echo "Copyright (C) 2014-2016 the Wine Staging project authors." echo "" echo "Patchset to be applied on upstream Wine:" @@ -338,6 +338,7 @@ patch_enable_all () enable_version_VerQueryValue="$1" enable_wbemdisp_ISWbemSecurity="$1" enable_widl_SLTG_Typelib_Support="$1" + enable_windowscodecs_32bppGrayFloat="$1" enable_wine_inf_Performance="$1" enable_wine_inf_ProfileList_UserSID="$1" enable_wine_inf_WMP_12="$1" @@ -1176,6 +1177,9 @@ patch_enable () widl-SLTG_Typelib_Support) enable_widl_SLTG_Typelib_Support="$2" ;; + windowscodecs-32bppGrayFloat) + enable_windowscodecs_32bppGrayFloat="$2" + ;; wine.inf-Performance) enable_wine_inf_Performance="$2" ;; @@ -6811,6 +6815,27 @@ if test "$enable_wbemdisp_ISWbemSecurity" -eq 1; then ) >> "$patchlist" fi +# Patchset windowscodecs-32bppGrayFloat +# | +# | This patchset fixes the following Wine bugs: +# | * [#36517] Implement support for WICPixelFormat32bppGrayFloat +# | +# | Modified files: +# | * dlls/windowscodecs/converter.c, dlls/windowscodecs/regsvr.c, dlls/windowscodecs/tests/converter.c, include/wincodec.idl +# | +if test "$enable_windowscodecs_32bppGrayFloat" -eq 1; then + patch_apply windowscodecs-32bppGrayFloat/0001-windowscodecs-Add-support-for-32bppGrayFloat-format.patch + patch_apply windowscodecs-32bppGrayFloat/0002-windowscodecs-Add-support-for-converting-to-8bpp-gra.patch + patch_apply windowscodecs-32bppGrayFloat/0003-windowscodecs-Add-support-for-converting-32bpp-grays.patch + patch_apply windowscodecs-32bppGrayFloat/0004-windowscodecs-Fix-32bppGrayFloat-to-8bppGray-convers.patch + ( + echo '+ { "Dmitry Timoshkov", "windowscodecs: Add support for 32bppGrayFloat format.", 1 },'; + echo '+ { "Dmitry Timoshkov", "windowscodecs: Add support for converting to 8bpp grayscale format.", 1 },'; + echo '+ { "Dmitry Timoshkov", "windowscodecs: Add support for converting 32bpp grayscale float to 24bpp BGR format.", 1 },'; + echo '+ { "Dmitry Timoshkov", "windowscodecs: Fix 32bppGrayFloat to 8bppGray conversion.", 1 },'; + ) >> "$patchlist" +fi + # Patchset wine.inf-Performance # | # | This patchset fixes the following Wine bugs: diff --git a/patches/windowscodecs-32bppGrayFloat/0001-windowscodecs-Add-support-for-32bppGrayFloat-format.patch b/patches/windowscodecs-32bppGrayFloat/0001-windowscodecs-Add-support-for-32bppGrayFloat-format.patch new file mode 100644 index 00000000..ce95d628 --- /dev/null +++ b/patches/windowscodecs-32bppGrayFloat/0001-windowscodecs-Add-support-for-32bppGrayFloat-format.patch @@ -0,0 +1,203 @@ +From 964980631537fea41619e05d09f1d14cf663755c Mon Sep 17 00:00:00 2001 +From: Dmitry Timoshkov +Date: Mon, 7 Mar 2016 15:38:19 +0800 +Subject: windowscodecs: Add support for 32bppGrayFloat format. + +For bug 36517. +--- + dlls/windowscodecs/converter.c | 45 ++++++++++++++++++++++++++++++++++ + dlls/windowscodecs/regsvr.c | 1 + + dlls/windowscodecs/tests/converter.c | 47 ++++++++++++++++++++++++++++++++++++ + include/wincodec.idl | 1 + + 4 files changed, 94 insertions(+) + +diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c +index 11f04d9..79b0a4b 100644 +--- a/dlls/windowscodecs/converter.c ++++ b/dlls/windowscodecs/converter.c +@@ -50,6 +50,7 @@ enum pixelformat { + format_16bppBGRA5551, + format_24bppBGR, + format_24bppRGB, ++ format_32bppGrayFloat, + format_32bppBGR, + format_32bppBGRA, + format_32bppPBGRA, +@@ -994,6 +995,49 @@ static HRESULT copypixels_to_24bppRGB(struct FormatConverter *This, const WICRec + } + } + ++static HRESULT copypixels_to_32bppGrayFloat(struct FormatConverter *This, const WICRect *prc, ++ UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) ++{ ++ HRESULT hr; ++ ++ switch (source_format) ++ { ++ case format_32bppBGR: ++ case format_32bppBGRA: ++ case format_32bppPBGRA: ++ case format_32bppGrayFloat: ++ if (prc) ++ { ++ hr = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); ++ break; ++ } ++ return S_OK; ++ ++ default: ++ hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format); ++ break; ++ } ++ ++ if (SUCCEEDED(hr) && prc && source_format != format_32bppGrayFloat) ++ { ++ INT x, y; ++ BYTE *p = pbBuffer; ++ ++ for (y = 0; y < prc->Height; y++) ++ { ++ BYTE *bgr = p; ++ for (x = 0; x < prc->Width; x++) ++ { ++ float gray = (bgr[2] * 0.2126f + bgr[1] * 0.7152f + bgr[0] * 0.0722f) / 255.0f; ++ *(float *)bgr = gray; ++ bgr += 4; ++ } ++ p += cbStride; ++ } ++ } ++ return hr; ++} ++ + static const struct pixelformatinfo supported_formats[] = { + {format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL}, + {format_2bppIndexed, &GUID_WICPixelFormat2bppIndexed, NULL}, +@@ -1009,6 +1053,7 @@ static const struct pixelformatinfo supported_formats[] = { + {format_16bppBGRA5551, &GUID_WICPixelFormat16bppBGRA5551, NULL}, + {format_24bppBGR, &GUID_WICPixelFormat24bppBGR, copypixels_to_24bppBGR}, + {format_24bppRGB, &GUID_WICPixelFormat24bppRGB, copypixels_to_24bppRGB}, ++ {format_32bppGrayFloat, &GUID_WICPixelFormat32bppGrayFloat, copypixels_to_32bppGrayFloat}, + {format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR}, + {format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA}, + {format_32bppPBGRA, &GUID_WICPixelFormat32bppPBGRA, copypixels_to_32bppPBGRA}, +diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c +index ccb78b8..08aeb06 100644 +--- a/dlls/windowscodecs/regsvr.c ++++ b/dlls/windowscodecs/regsvr.c +@@ -1454,6 +1454,7 @@ static GUID const * const converter_formats[] = { + &GUID_WICPixelFormat32bppBGR, + &GUID_WICPixelFormat32bppBGRA, + &GUID_WICPixelFormat32bppPBGRA, ++ &GUID_WICPixelFormat32bppGrayFloat, + &GUID_WICPixelFormat48bppRGB, + &GUID_WICPixelFormat64bppRGBA, + &GUID_WICPixelFormat32bppCMYK, +diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c +index 00ea483..6a5fc4f 100644 +--- a/dlls/windowscodecs/tests/converter.c ++++ b/dlls/windowscodecs/tests/converter.c +@@ -43,6 +43,11 @@ typedef struct BitmapTestSrc { + const bitmap_data *data; + } BitmapTestSrc; + ++static BOOL near_equal(float a, float b) ++{ ++ return fabsf(a - b) < 0.001; ++} ++ + static inline BitmapTestSrc *impl_from_IWICBitmapSource(IWICBitmapSource *iface) + { + return CONTAINING_RECORD(iface, BitmapTestSrc, IWICBitmapSource_iface); +@@ -196,6 +201,11 @@ static void DeleteTestBitmap(BitmapTestSrc *This) + HeapFree(GetProcessHeap(), 0, This); + } + ++/* XP and 2003 use linear color conversion, later versions use sRGB gamma */ ++static const float bits_32bppGrayFloat_xp[] = { ++ 0.114000f,0.587000f,0.299000f,0.000000f, ++ 0.886000f,0.413000f,0.701000f,1.000000f}; ++ + static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSource *source, const char *name) + { + BYTE *converted_bits; +@@ -245,6 +255,20 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour + } + ok(equal, "unexpected pixel data (%s)\n", name); + } ++ else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppGrayFloat)) ++ { ++ BOOL equal=TRUE; ++ UINT i; ++ const float *a=(const float*)expect->bits, *b=(const float*)converted_bits; ++ for (i=0; i<(buffersize/4); i++) ++ if (!near_equal(a[i], b[i]) && !near_equal(bits_32bppGrayFloat_xp[i], b[i])) ++ { ++ equal = FALSE; ++ break; ++ } ++ ++ ok(equal, "unexpected pixel data (%s)\n", name); ++ } + else + ok(memcmp(expect->bits, converted_bits, buffersize) == 0, "unexpected pixel data (%s)\n", name); + +@@ -265,6 +289,20 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour + } + ok(equal, "unexpected pixel data with rc=NULL (%s)\n", name); + } ++ else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppGrayFloat)) ++ { ++ BOOL equal=TRUE; ++ UINT i; ++ const float *a=(const float*)expect->bits, *b=(const float*)converted_bits; ++ for (i=0; i<(buffersize/4); i++) ++ if (!near_equal(a[i], b[i]) && !near_equal(bits_32bppGrayFloat_xp[i], b[i])) ++ { ++ equal = FALSE; ++ break; ++ } ++ ++ ok(equal, "unexpected pixel data (%s)\n", name); ++ } + else + ok(memcmp(expect->bits, converted_bits, buffersize) == 0, "unexpected pixel data with rc=NULL (%s)\n", name); + +@@ -295,6 +333,12 @@ static const BYTE bits_32bppBGRA[] = { + static const struct bitmap_data testdata_32bppBGRA = { + &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA, 4, 2, 96.0, 96.0}; + ++static const float bits_32bppGrayFloat[] = { ++ 0.072200f,0.715200f,0.212600f,0.000000f, ++ 0.927800f,0.284800f,0.787400f,1.000000f}; ++static const struct bitmap_data testdata_32bppGrayFloat = { ++ &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat, 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; +@@ -734,6 +778,9 @@ START_TEST(converter) + test_conversion(&testdata_32bppBGR, &testdata_24bppRGB, "32bppBGR -> 24bppRGB", FALSE); + test_conversion(&testdata_24bppRGB, &testdata_32bppBGR, "24bppRGB -> 32bppBGR", FALSE); + ++ test_conversion(&testdata_24bppRGB, &testdata_32bppGrayFloat, "24bppRGB -> 32bppGrayFloat", FALSE); ++ test_conversion(&testdata_32bppBGR, &testdata_32bppGrayFloat, "32bppBGR -> 32bppGrayFloat", FALSE); ++ + test_invalid_conversion(); + test_default_converter(); + +diff --git a/include/wincodec.idl b/include/wincodec.idl +index 639d925..83daba8 100644 +--- a/include/wincodec.idl ++++ b/include/wincodec.idl +@@ -196,6 +196,7 @@ cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppPBGRA, 0x6fddc324,0x4e03,0x4bfe,0 + cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppRGB, 0xd98c6b95,0x3efe,0x47d6,0xbb,0x25,0xeb,0x17,0x48,0xab,0x0c,0xf1);") + cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppRGBA, 0xf5c7ad2d,0x6a8d,0x43dd,0xa7,0xa8,0xa2,0x99,0x35,0x26,0x1a,0xe9);") + cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppPRGBA, 0x3cc4a650,0xa527,0x4d37,0xa9,0x16,0x31,0x42,0xc7,0xeb,0xed,0xba);") ++cpp_quote("DEFINE_GUID(GUID_WICPixelFormat32bppGrayFloat, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x11);") + + cpp_quote("DEFINE_GUID(GUID_WICPixelFormat48bppRGB, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x15);") + cpp_quote("DEFINE_GUID(GUID_WICPixelFormat64bppRGBA, 0x6fddc324,0x4e03,0x4bfe,0xb1,0x85,0x3d,0x77,0x76,0x8d,0xc9,0x16);") +-- +2.7.1 + diff --git a/patches/windowscodecs-32bppGrayFloat/0002-windowscodecs-Add-support-for-converting-to-8bpp-gra.patch b/patches/windowscodecs-32bppGrayFloat/0002-windowscodecs-Add-support-for-converting-to-8bpp-gra.patch new file mode 100644 index 00000000..b3f9832a --- /dev/null +++ b/patches/windowscodecs-32bppGrayFloat/0002-windowscodecs-Add-support-for-converting-to-8bpp-gra.patch @@ -0,0 +1,229 @@ +From 60fa6d906b5a090e2dcf371d5c1de41c040baf33 Mon Sep 17 00:00:00 2001 +From: Dmitry Timoshkov +Date: Mon, 7 Mar 2016 16:20:51 +0800 +Subject: windowscodecs: Add support for converting to 8bpp grayscale format. + +--- + dlls/windowscodecs/converter.c | 101 ++++++++++++++++++++++++++++++++++- + dlls/windowscodecs/tests/converter.c | 38 +++++++++++++ + 2 files changed, 138 insertions(+), 1 deletion(-) + +diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c +index 79b0a4b..7fc8a9c 100644 +--- a/dlls/windowscodecs/converter.c ++++ b/dlls/windowscodecs/converter.c +@@ -1,5 +1,6 @@ + /* + * Copyright 2009 Vincent Povirk ++ * Copyright 2016 Dmitry Timoshkov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public +@@ -19,6 +20,7 @@ + #include "config.h" + + #include ++#include + + #define COBJMACROS + +@@ -79,6 +81,55 @@ typedef struct FormatConverter { + CRITICAL_SECTION lock; /* must be held when initialized */ + } FormatConverter; + ++/* https://www.w3.org/Graphics/Color/srgb */ ++static inline float from_sRGB_component(float f) ++{ ++ if (f <= 0.04045f) return f / 12.92f; ++ return powf((f + 0.055f) / 1.055f, 2.4f); ++} ++ ++static inline float to_sRGB_component(float f) ++{ ++ if (f <= 0.0031308f) return 12.92f * f; ++ return 1.055f * powf(f, 1.0f/2.4f) - 0.055f; ++} ++ ++#if 0 /* FIXME: enable once needed */ ++static void from_sRGB(BYTE *bgr) ++{ ++ float r, g, b; ++ ++ r = bgr[2] / 255.0f; ++ g = bgr[1] / 255.0f; ++ b = bgr[0] / 255.0f; ++ ++ r = from_sRGB_component(r); ++ g = from_sRGB_component(g); ++ g = from_sRGB_component(b); ++ ++ bgr[2] = (BYTE)(r * 255.0f); ++ bgr[1] = (BYTE)(g * 255.0f); ++ bgr[0] = (BYTE)(b * 255.0f); ++} ++ ++static void to_sRGB(BYTE *bgr) ++{ ++ float r, g, b; ++ ++ r = bgr[2] / 255.0f; ++ g = bgr[1] / 255.0f; ++ b = bgr[0] / 255.0f; ++ ++ r = to_sRGB_component(r); ++ g = to_sRGB_component(g); ++ g = to_sRGB_component(b); ++ ++ bgr[2] = (BYTE)(r * 255.0f); ++ bgr[1] = (BYTE)(g * 255.0f); ++ bgr[0] = (BYTE)(b * 255.0f); ++} ++#endif ++ + static inline FormatConverter *impl_from_IWICFormatConverter(IWICFormatConverter *iface) + { + return CONTAINING_RECORD(iface, FormatConverter, IWICFormatConverter_iface); +@@ -1038,6 +1089,54 @@ static HRESULT copypixels_to_32bppGrayFloat(struct FormatConverter *This, const + return hr; + } + ++static HRESULT copypixels_to_8bppGray(struct FormatConverter *This, const WICRect *prc, ++ UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format) ++{ ++ HRESULT hr; ++ BYTE *srcdata; ++ UINT srcstride, srcdatasize; ++ ++ if (source_format == format_8bppGray) ++ { ++ if (prc) ++ return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer); ++ ++ return S_OK; ++ } ++ ++ srcstride = 3 * prc->Width; ++ srcdatasize = srcstride * prc->Height; ++ ++ srcdata = HeapAlloc(GetProcessHeap(), 0, srcdatasize); ++ if (!srcdata) return E_OUTOFMEMORY; ++ ++ hr = copypixels_to_24bppBGR(This, prc, srcstride, srcdatasize, srcdata, source_format); ++ if (SUCCEEDED(hr) && prc) ++ { ++ INT x, y; ++ BYTE *src = srcdata, *dst = pbBuffer; ++ ++ for (y = 0; y < prc->Height; y++) ++ { ++ BYTE *bgr = src; ++ ++ for (x = 0; x < prc->Width; x++) ++ { ++ float gray = (bgr[2] * 0.2126f + bgr[1] * 0.7152f + bgr[0] * 0.0722f) / 255.0f; ++ ++ gray = to_sRGB_component(gray) * 255.0f; ++ dst[x] = (BYTE)floorf(gray + 0.51f); ++ bgr += 3; ++ } ++ src += srcstride; ++ dst += cbStride; ++ } ++ } ++ ++ HeapFree(GetProcessHeap(), 0, srcdata); ++ return hr; ++} ++ + static const struct pixelformatinfo supported_formats[] = { + {format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL}, + {format_2bppIndexed, &GUID_WICPixelFormat2bppIndexed, NULL}, +@@ -1046,7 +1145,7 @@ static const struct pixelformatinfo supported_formats[] = { + {format_BlackWhite, &GUID_WICPixelFormatBlackWhite, NULL}, + {format_2bppGray, &GUID_WICPixelFormat2bppGray, NULL}, + {format_4bppGray, &GUID_WICPixelFormat4bppGray, NULL}, +- {format_8bppGray, &GUID_WICPixelFormat8bppGray, NULL}, ++ {format_8bppGray, &GUID_WICPixelFormat8bppGray, copypixels_to_8bppGray}, + {format_16bppGray, &GUID_WICPixelFormat16bppGray, NULL}, + {format_16bppBGR555, &GUID_WICPixelFormat16bppBGR555, NULL}, + {format_16bppBGR565, &GUID_WICPixelFormat16bppBGR565, NULL}, +diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c +index 6a5fc4f..a0a5d31 100644 +--- a/dlls/windowscodecs/tests/converter.c ++++ b/dlls/windowscodecs/tests/converter.c +@@ -205,6 +205,9 @@ static void DeleteTestBitmap(BitmapTestSrc *This) + static const float bits_32bppGrayFloat_xp[] = { + 0.114000f,0.587000f,0.299000f,0.000000f, + 0.886000f,0.413000f,0.701000f,1.000000f}; ++static const BYTE bits_8bppGray_xp[] = { ++ 29,150,76,0, ++ 226,105,179,255}; + + static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSource *source, const char *name) + { +@@ -269,6 +272,19 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour + + ok(equal, "unexpected pixel data (%s)\n", name); + } ++ else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat8bppGray)) ++ { ++ UINT i; ++ BOOL equal=TRUE; ++ const BYTE *a=(const BYTE*)expect->bits, *b=(const BYTE*)converted_bits; ++ for (i=0; ibits, converted_bits, buffersize) == 0, "unexpected pixel data (%s)\n", name); + +@@ -303,6 +319,19 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour + + ok(equal, "unexpected pixel data (%s)\n", name); + } ++ else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat8bppGray)) ++ { ++ UINT i; ++ BOOL equal=TRUE; ++ const BYTE *a=(const BYTE*)expect->bits, *b=(const BYTE*)converted_bits; ++ for (i=0; ibits, converted_bits, buffersize) == 0, "unexpected pixel data with rc=NULL (%s)\n", name); + +@@ -339,6 +368,12 @@ static const float bits_32bppGrayFloat[] = { + static const struct bitmap_data testdata_32bppGrayFloat = { + &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat, 4, 2, 96.0, 96.0}; + ++static const BYTE bits_8bppGray[] = { ++ 76,220,127,0, ++ 247,145,230,255}; ++static const struct bitmap_data testdata_8bppGray = { ++ &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray, 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; +@@ -781,6 +816,9 @@ START_TEST(converter) + test_conversion(&testdata_24bppRGB, &testdata_32bppGrayFloat, "24bppRGB -> 32bppGrayFloat", FALSE); + test_conversion(&testdata_32bppBGR, &testdata_32bppGrayFloat, "32bppBGR -> 32bppGrayFloat", FALSE); + ++ test_conversion(&testdata_24bppBGR, &testdata_8bppGray, "24bppBGR -> 8bppGray", FALSE); ++ test_conversion(&testdata_32bppBGR, &testdata_8bppGray, "32bppBGR -> 8bppGray", FALSE); ++ + test_invalid_conversion(); + test_default_converter(); + +-- +2.7.1 + diff --git a/patches/windowscodecs-32bppGrayFloat/0003-windowscodecs-Add-support-for-converting-32bpp-grays.patch b/patches/windowscodecs-32bppGrayFloat/0003-windowscodecs-Add-support-for-converting-32bpp-grays.patch new file mode 100644 index 00000000..ae1efed4 --- /dev/null +++ b/patches/windowscodecs-32bppGrayFloat/0003-windowscodecs-Add-support-for-converting-32bpp-grays.patch @@ -0,0 +1,93 @@ +From eec7fc946887f9f93de2bc2c00cb171f0de5bb53 Mon Sep 17 00:00:00 2001 +From: Dmitry Timoshkov +Date: Mon, 7 Mar 2016 17:22:55 +0800 +Subject: windowscodecs: Add support for converting 32bpp grayscale float to + 24bpp BGR format. + +--- + dlls/windowscodecs/converter.c | 43 ++++++++++++++++++++++++++++++++++++ + dlls/windowscodecs/tests/converter.c | 7 ++++++ + 2 files changed, 50 insertions(+) + +diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c +index 7fc8a9c..322b2d1 100644 +--- a/dlls/windowscodecs/converter.c ++++ b/dlls/windowscodecs/converter.c +@@ -970,6 +970,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; +diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c +index a0a5d31..9dd77a5 100644 +--- a/dlls/windowscodecs/tests/converter.c ++++ b/dlls/windowscodecs/tests/converter.c +@@ -374,6 +374,12 @@ static const BYTE bits_8bppGray[] = { + static const struct bitmap_data testdata_8bppGray = { + &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray, 4, 2, 96.0, 96.0}; + ++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; +@@ -818,6 +824,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(); +-- +2.7.1 + diff --git a/patches/windowscodecs-32bppGrayFloat/0004-windowscodecs-Fix-32bppGrayFloat-to-8bppGray-convers.patch b/patches/windowscodecs-32bppGrayFloat/0004-windowscodecs-Fix-32bppGrayFloat-to-8bppGray-convers.patch new file mode 100644 index 00000000..121799a7 --- /dev/null +++ b/patches/windowscodecs-32bppGrayFloat/0004-windowscodecs-Fix-32bppGrayFloat-to-8bppGray-convers.patch @@ -0,0 +1,44 @@ +From 6d2db3592f0eccdef65691c51d16e3bb7558e8ae Mon Sep 17 00:00:00 2001 +From: Dmitry Timoshkov +Date: Mon, 7 Mar 2016 17:36:39 +0800 +Subject: windowscodecs: Fix 32bppGrayFloat to 8bppGray conversion. + +Intermediate conversion from 32bppGrayFloat to 24bppBGR applies sRGB gamma. +--- + dlls/windowscodecs/converter.c | 7 ++++++- + dlls/windowscodecs/tests/converter.c | 1 + + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c +index 322b2d1..bd5e978 100644 +--- a/dlls/windowscodecs/converter.c ++++ b/dlls/windowscodecs/converter.c +@@ -1167,7 +1167,12 @@ static HRESULT copypixels_to_8bppGray(struct FormatConverter *This, const WICRec + { + float gray = (bgr[2] * 0.2126f + bgr[1] * 0.7152f + bgr[0] * 0.0722f) / 255.0f; + +- gray = to_sRGB_component(gray) * 255.0f; ++ /* conversion from 32bppGrayFloat to 24bppBGR has already applied sRGB gamma */ ++ if (source_format == format_32bppGrayFloat) ++ gray *= 255.0f; ++ else ++ gray = to_sRGB_component(gray) * 255.0f; ++ + dst[x] = (BYTE)floorf(gray + 0.51f); + bgr += 3; + } +diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c +index 9dd77a5..80766ea 100644 +--- a/dlls/windowscodecs/tests/converter.c ++++ b/dlls/windowscodecs/tests/converter.c +@@ -825,6 +825,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(); +-- +2.7.1 + diff --git a/patches/windowscodecs-32bppGrayFloat/definition b/patches/windowscodecs-32bppGrayFloat/definition new file mode 100644 index 00000000..a25dbf8a --- /dev/null +++ b/patches/windowscodecs-32bppGrayFloat/definition @@ -0,0 +1 @@ +Fixes: [36517] Implement support for WICPixelFormat32bppGrayFloat diff --git a/staging/VERSION b/staging/VERSION index a7d6e90b..60853b1a 100644 --- a/staging/VERSION +++ b/staging/VERSION @@ -1 +1 @@ -Wine Staging 1.9.5 +Wine Staging 1.9.6 (unreleased)