mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
Rebase against e2ebc0dc23f0fa04ea79cefc9e3d2faf189a6bf7.
[windowscodecs-32bppGrayFloat] Partially removed patches to implement support for WICPixelFormat32bppGrayFloat (accepted upstream). [windowscodecs-copypixels_to_24bppRGB] Removed patch to avoid extra conversion step BGR->RGB when converting 32bpp BGRA to 24bpp RGB (accepted upstream).
This commit is contained in:
parent
f8b5d1530a
commit
522961364f
@ -52,7 +52,7 @@ usage()
|
||||
# Get the upstream commit sha
|
||||
upstream_commit()
|
||||
{
|
||||
echo "1938d389b293930c5ac2f2970c6241e09517cf49"
|
||||
echo "e2ebc0dc23f0fa04ea79cefc9e3d2faf189a6bf7"
|
||||
}
|
||||
|
||||
# Show version information
|
||||
@ -352,7 +352,6 @@ patch_enable_all ()
|
||||
enable_windowscodecs_IMILBitmapSource="$1"
|
||||
enable_windowscodecs_IWICPalette_InitializeFromBitmap="$1"
|
||||
enable_windowscodecs_WICCreateBitmapFromSection="$1"
|
||||
enable_windowscodecs_copypixels_to_24bppRGB="$1"
|
||||
enable_wine_inf_Directory_ContextMenuHandlers="$1"
|
||||
enable_wine_inf_Dummy_CA_Certificate="$1"
|
||||
enable_wine_inf_Performance="$1"
|
||||
@ -1236,9 +1235,6 @@ patch_enable ()
|
||||
windowscodecs-WICCreateBitmapFromSection)
|
||||
enable_windowscodecs_WICCreateBitmapFromSection="$2"
|
||||
;;
|
||||
windowscodecs-copypixels_to_24bppRGB)
|
||||
enable_windowscodecs_copypixels_to_24bppRGB="$2"
|
||||
;;
|
||||
wine.inf-Directory_ContextMenuHandlers)
|
||||
enable_wine_inf_Directory_ContextMenuHandlers="$2"
|
||||
;;
|
||||
@ -2043,13 +2039,6 @@ if test "$enable_windowscodecs_IWICPalette_InitializeFromBitmap" -eq 1; then
|
||||
enable_gdiplus_Grayscale_PNG=1
|
||||
fi
|
||||
|
||||
if test "$enable_windowscodecs_32bppGrayFloat" -eq 1; then
|
||||
if test "$enable_windowscodecs_copypixels_to_24bppRGB" -gt 1; then
|
||||
abort "Patchset windowscodecs-copypixels_to_24bppRGB disabled, but windowscodecs-32bppGrayFloat depends on that."
|
||||
fi
|
||||
enable_windowscodecs_copypixels_to_24bppRGB=1
|
||||
fi
|
||||
|
||||
if test "$enable_uxtheme_GTK_Theming" -eq 1; then
|
||||
if test "$enable_ntdll_DllRedirects" -gt 1; then
|
||||
abort "Patchset ntdll-DllRedirects disabled, but uxtheme-GTK_Theming depends on that."
|
||||
@ -7137,38 +7126,17 @@ if test "$enable_wbemdisp_Printer" -eq 1; then
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset windowscodecs-copypixels_to_24bppRGB
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/windowscodecs/converter.c, dlls/windowscodecs/tests/converter.c
|
||||
# |
|
||||
if test "$enable_windowscodecs_copypixels_to_24bppRGB" -eq 1; then
|
||||
patch_apply windowscodecs-copypixels_to_24bppRGB/0001-windowscodecs-Avoid-extra-conversion-step-BGR-RGB-wh.patch
|
||||
(
|
||||
echo '+ { "Dmitry Timoshkov", "windowscodecs: Avoid extra conversion step BGR->RGB when converting 32bpp BGRA to 24bpp RGB.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset windowscodecs-32bppGrayFloat
|
||||
# |
|
||||
# | This patchset has the following (direct or indirect) dependencies:
|
||||
# | * windowscodecs-copypixels_to_24bppRGB
|
||||
# |
|
||||
# | 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
|
||||
# | * dlls/windowscodecs/converter.c, dlls/windowscodecs/tests/converter.c
|
||||
# |
|
||||
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
|
||||
|
@ -1,203 +0,0 @@
|
||||
From f81f47092ea27fc5dbe08e89a0daea1c7bcbc0c4 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
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 efe78d8..21301cb 100644
|
||||
--- a/dlls/windowscodecs/converter.c
|
||||
+++ b/dlls/windowscodecs/converter.c
|
||||
@@ -49,6 +49,7 @@ enum pixelformat {
|
||||
format_16bppBGRA5551,
|
||||
format_24bppBGR,
|
||||
format_24bppRGB,
|
||||
+ format_32bppGrayFloat,
|
||||
format_32bppBGR,
|
||||
format_32bppBGRA,
|
||||
format_32bppPBGRA,
|
||||
@@ -996,6 +997,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},
|
||||
@@ -1011,6 +1055,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 ff499e5..10a6c03 100644
|
||||
--- a/dlls/windowscodecs/regsvr.c
|
||||
+++ b/dlls/windowscodecs/regsvr.c
|
||||
@@ -1452,6 +1452,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 c1599c5..1386a32 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;
|
||||
@@ -735,6 +779,9 @@ START_TEST(converter)
|
||||
test_conversion(&testdata_24bppRGB, &testdata_32bppBGR, "24bppRGB -> 32bppBGR", FALSE);
|
||||
test_conversion(&testdata_32bppBGRA, &testdata_24bppRGB, "32bppBGRA -> 24bppRGB", 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.9.0
|
||||
|
@ -1,229 +0,0 @@
|
||||
From 60fa6d906b5a090e2dcf371d5c1de41c040baf33 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
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 <stdarg.h>
|
||||
+#include <math.h>
|
||||
|
||||
#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; i<buffersize; i++)
|
||||
+ if (a[i] != b[i] && bits_8bppGray_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);
|
||||
|
||||
@@ -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; i<buffersize; i++)
|
||||
+ if (a[i] != b[i] && bits_8bppGray_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);
|
||||
|
||||
@@ -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
|
||||
|
@ -1,93 +0,0 @@
|
||||
From eec7fc946887f9f93de2bc2c00cb171f0de5bb53 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
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
|
||||
|
@ -1,2 +1 @@
|
||||
Fixes: [36517] Implement support for WICPixelFormat32bppGrayFloat
|
||||
Depends: windowscodecs-copypixels_to_24bppRGB
|
||||
|
@ -1,64 +0,0 @@
|
||||
From ab3e666b4da856b468ac4eb56b0cd349894d7b50 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Mon, 29 Aug 2016 15:22:08 +0800
|
||||
Subject: windowscodecs: Avoid extra conversion step BGR->RGB when converting
|
||||
32bpp BGRA to 24bpp RGB.
|
||||
|
||||
This avoids double conversion and improves conversion time.
|
||||
24bpp RGB to 32bpp BGRA already does it this way.
|
||||
---
|
||||
dlls/windowscodecs/converter.c | 13 ++++++++-----
|
||||
dlls/windowscodecs/tests/converter.c | 1 +
|
||||
2 files changed, 9 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
|
||||
index e701f2a..efe78d8 100644
|
||||
--- a/dlls/windowscodecs/converter.c
|
||||
+++ b/dlls/windowscodecs/converter.c
|
||||
@@ -953,6 +953,7 @@ static HRESULT copypixels_to_24bppRGB(struct FormatConverter *This, const WICRec
|
||||
const BYTE *srcpixel;
|
||||
BYTE *dstrow;
|
||||
BYTE *dstpixel;
|
||||
+ BYTE tmppixel[3];
|
||||
|
||||
srcstride = 4 * prc->Width;
|
||||
srcdatasize = srcstride * prc->Height;
|
||||
@@ -970,16 +971,18 @@ static HRESULT copypixels_to_24bppRGB(struct FormatConverter *This, const WICRec
|
||||
srcpixel=srcrow;
|
||||
dstpixel=dstrow;
|
||||
for (x=0; x<prc->Width; x++) {
|
||||
- *dstpixel++=*srcpixel++; /* blue */
|
||||
- *dstpixel++=*srcpixel++; /* green */
|
||||
- *dstpixel++=*srcpixel++; /* red */
|
||||
+ tmppixel[0]=*srcpixel++; /* blue */
|
||||
+ tmppixel[1]=*srcpixel++; /* green */
|
||||
+ tmppixel[2]=*srcpixel++; /* red */
|
||||
srcpixel++; /* alpha */
|
||||
+
|
||||
+ *dstpixel++=tmppixel[2]; /* red */
|
||||
+ *dstpixel++=tmppixel[1]; /* green */
|
||||
+ *dstpixel++=tmppixel[0]; /* blue */
|
||||
}
|
||||
srcrow += srcstride;
|
||||
dstrow += cbStride;
|
||||
}
|
||||
-
|
||||
- reverse_bgr8(3, pbBuffer, prc->Width, prc->Height, cbStride);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, srcdata);
|
||||
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
|
||||
index 8c7a10f..c1599c5 100644
|
||||
--- a/dlls/windowscodecs/tests/converter.c
|
||||
+++ b/dlls/windowscodecs/tests/converter.c
|
||||
@@ -733,6 +733,7 @@ START_TEST(converter)
|
||||
|
||||
test_conversion(&testdata_32bppBGR, &testdata_24bppRGB, "32bppBGR -> 24bppRGB", FALSE);
|
||||
test_conversion(&testdata_24bppRGB, &testdata_32bppBGR, "24bppRGB -> 32bppBGR", FALSE);
|
||||
+ test_conversion(&testdata_32bppBGRA, &testdata_24bppRGB, "32bppBGRA -> 24bppRGB", FALSE);
|
||||
|
||||
test_invalid_conversion();
|
||||
test_default_converter();
|
||||
--
|
||||
2.9.0
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 58d6b57b0fb8ba53e8daef409dc345aa12cbb64b Mon Sep 17 00:00:00 2001
|
||||
From 74bd99f226b3bb69b58e7b8a9d54d10e400b0533 Mon Sep 17 00:00:00 2001
|
||||
From: Damjan Jovanovic <damjan.jov@gmail.com>
|
||||
Date: Fri, 8 Aug 2014 20:05:54 +0200
|
||||
Subject: winex11.drv: Import X11's "text/html" as "HTML Format". (try 3)
|
||||
@ -11,35 +11,31 @@ Changes by Sebastian Lackner <sebastian@fds-team.de>:
|
||||
* Fix incorrect detection of startOfMarkup
|
||||
* Some small formatting fixes
|
||||
---
|
||||
dlls/winex11.drv/clipboard.c | 204 ++++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 203 insertions(+), 1 deletion(-)
|
||||
dlls/winex11.drv/clipboard.c | 203 ++++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 202 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
|
||||
index b2705b4..a2a5889 100644
|
||||
index 190935c..b750e2e 100644
|
||||
--- a/dlls/winex11.drv/clipboard.c
|
||||
+++ b/dlls/winex11.drv/clipboard.c
|
||||
@@ -148,6 +148,7 @@ static HANDLE X11DRV_CLIPBOARD_ImportImageBmp(Display *d, Window w, Atom prop);
|
||||
static HANDLE X11DRV_CLIPBOARD_ImportXAString(Display *d, Window w, Atom prop);
|
||||
static HANDLE X11DRV_CLIPBOARD_ImportUTF8(Display *d, Window w, Atom prop);
|
||||
static HANDLE X11DRV_CLIPBOARD_ImportCompoundText(Display *d, Window w, Atom prop);
|
||||
+static HANDLE X11DRV_CLIPBOARD_ImportTextHtml(Display *display, Window w, Atom prop);
|
||||
static HANDLE X11DRV_CLIPBOARD_ImportTextUriList(Display *display, Window w, Atom prop);
|
||||
static HANDLE X11DRV_CLIPBOARD_ExportClipboardData(Display *display, Window requestor, Atom aTarget,
|
||||
Atom rprop, LPWINE_CLIPDATA lpData, LPDWORD lpBytes);
|
||||
@@ -343,10 +344,11 @@ void X11DRV_InitClipboard(void)
|
||||
X11DRV_CLIPBOARD_InsertClipboardFormat( RegisterClipboardFormatW(PropertyFormatMap[i].lpszFormat),
|
||||
GET_ATOM(PropertyFormatMap[i].prop));
|
||||
@@ -134,6 +134,7 @@ static HANDLE import_image_bmp(Display *d, Window w, Atom prop);
|
||||
static HANDLE import_string(Display *d, Window w, Atom prop);
|
||||
static HANDLE import_utf8_string(Display *d, Window w, Atom prop);
|
||||
static HANDLE import_compound_text(Display *d, Window w, Atom prop);
|
||||
+static HANDLE import_text_html(Display *display, Window w, Atom prop);
|
||||
static HANDLE import_text_uri_list(Display *display, Window w, Atom prop);
|
||||
|
||||
- /* Set up a conversion function from "HTML Format" to "text/html" */
|
||||
+ /* Set up a conversion function between "HTML Format" and "text/html" */
|
||||
format = X11DRV_CLIPBOARD_InsertClipboardFormat( RegisterClipboardFormatW(wszHTMLFormat),
|
||||
GET_ATOM(XATOM_text_html));
|
||||
format->lpDrvExportFunc = X11DRV_CLIPBOARD_ExportTextHtml;
|
||||
+ format->lpDrvImportFunc = X11DRV_CLIPBOARD_ImportTextHtml;
|
||||
}
|
||||
static HANDLE export_data(Display *display, Window requestor, Atom aTarget,
|
||||
@@ -210,7 +211,7 @@ static const struct
|
||||
{ JFIFW, 0, XATOM_image_jpeg, import_data, export_data },
|
||||
{ PNGW, 0, XATOM_image_png, import_data, export_data },
|
||||
{ HTMLFormatW, 0, XATOM_HTML_Format, import_data, export_data },
|
||||
- { HTMLFormatW, 0, XATOM_text_html, import_data, export_text_html },
|
||||
+ { HTMLFormatW, 0, XATOM_text_html, import_text_html, export_text_html },
|
||||
};
|
||||
|
||||
|
||||
@@ -1568,6 +1570,206 @@ static HANDLE X11DRV_CLIPBOARD_ImportEnhMetaFile(Display *display, Window w, Ato
|
||||
static struct list format_list = LIST_INIT( format_list );
|
||||
@@ -1172,6 +1173,206 @@ static HANDLE import_enhmetafile(Display *display, Window w, Atom prop)
|
||||
}
|
||||
|
||||
|
||||
@ -155,11 +151,11 @@ index b2705b4..a2a5889 100644
|
||||
+
|
||||
+
|
||||
+/**************************************************************************
|
||||
+ * X11DRV_CLIPBOARD_ImportTextHtml
|
||||
+ * import_text_html
|
||||
+ *
|
||||
+ * Import text/html into "HTML Format".
|
||||
+ */
|
||||
+static HANDLE X11DRV_CLIPBOARD_ImportTextHtml(Display *display, Window w, Atom prop)
|
||||
+static HANDLE import_text_html(Display *display, Window w, Atom prop)
|
||||
+{
|
||||
+ static const char startFragment[] = "<!--StartFragment -->";
|
||||
+ static const char endFragment[] = "<!--EndFragment -->";
|
||||
@ -244,8 +240,8 @@ index b2705b4..a2a5889 100644
|
||||
+
|
||||
+
|
||||
/**************************************************************************
|
||||
* X11DRV_CLIPBOARD_ImportTextUriList
|
||||
* import_text_uri_list
|
||||
*
|
||||
--
|
||||
2.1.2
|
||||
2.9.0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user