You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-09-12 18:50:20 -07:00
Added patch to implement support for 32bppRGB, 32bppRGBA and 32bppPRGBA in format converter.
This commit is contained in:
@@ -0,0 +1,215 @@
|
||||
From 19602d837ac30e24f629eeae62238eb9fbe4adcc Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Mon, 23 Jan 2017 18:24:46 +0800
|
||||
Subject: windowscodecs: Add support for 32bppRGB, 32bppRGBA and 32bppPRGBA to
|
||||
format converter.
|
||||
|
||||
---
|
||||
dlls/windowscodecs/converter.c | 74 ++++++++++++++++++++++++++++++++++++++++++
|
||||
dlls/windowscodecs/info.c | 2 ++
|
||||
dlls/windowscodecs/regsvr.c | 36 ++++++++++++++++++++
|
||||
3 files changed, 112 insertions(+)
|
||||
|
||||
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
|
||||
index 5561d423dce..519860d9065 100644
|
||||
--- a/dlls/windowscodecs/converter.c
|
||||
+++ b/dlls/windowscodecs/converter.c
|
||||
@@ -53,8 +53,11 @@ enum pixelformat {
|
||||
format_24bppRGB,
|
||||
format_32bppGrayFloat,
|
||||
format_32bppBGR,
|
||||
+ format_32bppRGB,
|
||||
format_32bppBGRA,
|
||||
+ format_32bppRGBA,
|
||||
format_32bppPBGRA,
|
||||
+ format_32bppPRGBA,
|
||||
format_48bppRGB,
|
||||
format_64bppRGBA,
|
||||
format_32bppCMYK,
|
||||
@@ -858,6 +861,25 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
|
||||
}
|
||||
}
|
||||
|
||||
+static HRESULT copypixels_to_32bppRGBA(struct FormatConverter *This, const WICRect *prc,
|
||||
+ UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
|
||||
+{
|
||||
+ HRESULT hr;
|
||||
+
|
||||
+ switch (source_format)
|
||||
+ {
|
||||
+ case format_32bppRGBA:
|
||||
+ if (prc)
|
||||
+ return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
|
||||
+ return S_OK;
|
||||
+ default:
|
||||
+ hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
|
||||
+ if (SUCCEEDED(hr) && prc)
|
||||
+ reverse_bgr8(4, pbBuffer, prc->Width, prc->Height, cbStride);
|
||||
+ return hr;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static HRESULT copypixels_to_32bppBGR(struct FormatConverter *This, const WICRect *prc,
|
||||
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
|
||||
{
|
||||
@@ -874,6 +896,22 @@ static HRESULT copypixels_to_32bppBGR(struct FormatConverter *This, const WICRec
|
||||
}
|
||||
}
|
||||
|
||||
+static HRESULT copypixels_to_32bppRGB(struct FormatConverter *This, const WICRect *prc,
|
||||
+ UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
|
||||
+{
|
||||
+ switch (source_format)
|
||||
+ {
|
||||
+ case format_32bppRGB:
|
||||
+ case format_32bppRGBA:
|
||||
+ case format_32bppPRGBA:
|
||||
+ if (prc)
|
||||
+ return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
|
||||
+ return S_OK;
|
||||
+ default:
|
||||
+ return copypixels_to_32bppRGBA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static HRESULT copypixels_to_32bppPBGRA(struct FormatConverter *This, const WICRect *prc,
|
||||
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
|
||||
{
|
||||
@@ -907,6 +945,39 @@ static HRESULT copypixels_to_32bppPBGRA(struct FormatConverter *This, const WICR
|
||||
}
|
||||
}
|
||||
|
||||
+static HRESULT copypixels_to_32bppPRGBA(struct FormatConverter *This, const WICRect *prc,
|
||||
+ UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
|
||||
+{
|
||||
+ HRESULT hr;
|
||||
+
|
||||
+ switch (source_format)
|
||||
+ {
|
||||
+ case format_32bppPRGBA:
|
||||
+ if (prc)
|
||||
+ return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
|
||||
+ return S_OK;
|
||||
+ default:
|
||||
+ hr = copypixels_to_32bppRGBA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
|
||||
+ if (SUCCEEDED(hr) && prc)
|
||||
+ {
|
||||
+ INT x, y;
|
||||
+
|
||||
+ for (y=0; y<prc->Height; y++)
|
||||
+ for (x=0; x<prc->Width; x++)
|
||||
+ {
|
||||
+ BYTE alpha = pbBuffer[cbStride*y+4*x+3];
|
||||
+ if (alpha != 255)
|
||||
+ {
|
||||
+ pbBuffer[cbStride*y+4*x] = pbBuffer[cbStride*y+4*x] * alpha / 255;
|
||||
+ pbBuffer[cbStride*y+4*x+1] = pbBuffer[cbStride*y+4*x+1] * alpha / 255;
|
||||
+ pbBuffer[cbStride*y+4*x+2] = pbBuffer[cbStride*y+4*x+2] * alpha / 255;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return hr;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static HRESULT copypixels_to_24bppBGR(struct FormatConverter *This, const WICRect *prc,
|
||||
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
|
||||
{
|
||||
@@ -1288,8 +1359,11 @@ static const struct pixelformatinfo supported_formats[] = {
|
||||
{format_24bppRGB, &GUID_WICPixelFormat24bppRGB, copypixels_to_24bppRGB},
|
||||
{format_32bppGrayFloat, &GUID_WICPixelFormat32bppGrayFloat, copypixels_to_32bppGrayFloat},
|
||||
{format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR},
|
||||
+ {format_32bppRGB, &GUID_WICPixelFormat32bppRGB, copypixels_to_32bppRGB},
|
||||
{format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA},
|
||||
+ {format_32bppRGBA, &GUID_WICPixelFormat32bppRGBA, copypixels_to_32bppRGBA},
|
||||
{format_32bppPBGRA, &GUID_WICPixelFormat32bppPBGRA, copypixels_to_32bppPBGRA},
|
||||
+ {format_32bppPRGBA, &GUID_WICPixelFormat32bppPRGBA, copypixels_to_32bppPRGBA},
|
||||
{format_48bppRGB, &GUID_WICPixelFormat48bppRGB, NULL},
|
||||
{format_64bppRGBA, &GUID_WICPixelFormat64bppRGBA, NULL},
|
||||
{format_32bppCMYK, &GUID_WICPixelFormat32bppCMYK, NULL},
|
||||
diff --git a/dlls/windowscodecs/info.c b/dlls/windowscodecs/info.c
|
||||
index 5e6244b9ccd..cc0123d60c6 100644
|
||||
--- a/dlls/windowscodecs/info.c
|
||||
+++ b/dlls/windowscodecs/info.c
|
||||
@@ -2302,6 +2302,8 @@ HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitma
|
||||
BOOL canconvert;
|
||||
ULONG num_fetched;
|
||||
|
||||
+ TRACE("%s,%p,%p\n", debugstr_guid(dstFormat), pISrc, ppIDst);
|
||||
+
|
||||
res = IWICBitmapSource_GetPixelFormat(pISrc, &srcFormat);
|
||||
if (FAILED(res)) return res;
|
||||
|
||||
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
|
||||
index b5bbff3b38f..308326cbdbc 100644
|
||||
--- a/dlls/windowscodecs/regsvr.c
|
||||
+++ b/dlls/windowscodecs/regsvr.c
|
||||
@@ -1480,8 +1480,11 @@ static GUID const * const converter_formats[] = {
|
||||
&GUID_WICPixelFormat24bppBGR,
|
||||
&GUID_WICPixelFormat24bppRGB,
|
||||
&GUID_WICPixelFormat32bppBGR,
|
||||
+ &GUID_WICPixelFormat32bppRGB,
|
||||
&GUID_WICPixelFormat32bppBGRA,
|
||||
+ &GUID_WICPixelFormat32bppRGBA,
|
||||
&GUID_WICPixelFormat32bppPBGRA,
|
||||
+ &GUID_WICPixelFormat32bppPRGBA,
|
||||
&GUID_WICPixelFormat32bppGrayFloat,
|
||||
&GUID_WICPixelFormat48bppRGB,
|
||||
&GUID_WICPixelFormat64bppRGBA,
|
||||
@@ -1945,6 +1948,17 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
|
||||
WICPixelFormatNumericRepresentationUnsignedInteger,
|
||||
0
|
||||
},
|
||||
+ { &GUID_WICPixelFormat32bppRGB,
|
||||
+ "The Wine Project",
|
||||
+ "32bpp RGB",
|
||||
+ NULL, /* no version */
|
||||
+ &GUID_VendorMicrosoft,
|
||||
+ 32, /* bitsperpixel */
|
||||
+ 3, /* channel count */
|
||||
+ channel_masks_8bit,
|
||||
+ WICPixelFormatNumericRepresentationUnsignedInteger,
|
||||
+ 0
|
||||
+ },
|
||||
{ &GUID_WICPixelFormat32bppBGRA,
|
||||
"The Wine Project",
|
||||
"32bpp BGRA",
|
||||
@@ -1956,6 +1970,17 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
|
||||
WICPixelFormatNumericRepresentationUnsignedInteger,
|
||||
1
|
||||
},
|
||||
+ { &GUID_WICPixelFormat32bppRGBA,
|
||||
+ "The Wine Project",
|
||||
+ "32bpp RGBA",
|
||||
+ NULL, /* no version */
|
||||
+ &GUID_VendorMicrosoft,
|
||||
+ 32, /* bitsperpixel */
|
||||
+ 4, /* channel count */
|
||||
+ channel_masks_8bit,
|
||||
+ WICPixelFormatNumericRepresentationUnsignedInteger,
|
||||
+ 1
|
||||
+ },
|
||||
{ &GUID_WICPixelFormat32bppPBGRA,
|
||||
"The Wine Project",
|
||||
"32bpp PBGRA",
|
||||
@@ -1967,6 +1992,17 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
|
||||
WICPixelFormatNumericRepresentationUnsignedInteger,
|
||||
1
|
||||
},
|
||||
+ { &GUID_WICPixelFormat32bppPRGBA,
|
||||
+ "The Wine Project",
|
||||
+ "32bpp PRGBA",
|
||||
+ NULL, /* no version */
|
||||
+ &GUID_VendorMicrosoft,
|
||||
+ 32, /* bitsperpixel */
|
||||
+ 4, /* channel count */
|
||||
+ channel_masks_8bit,
|
||||
+ WICPixelFormatNumericRepresentationUnsignedInteger,
|
||||
+ 1
|
||||
+ },
|
||||
{ &GUID_WICPixelFormat32bppGrayFloat,
|
||||
"The Wine Project",
|
||||
"32bpp GrayFloat",
|
||||
--
|
||||
2.11.0
|
||||
|
2
patches/windowscodecs-32bppPRGBA/definition
Normal file
2
patches/windowscodecs-32bppPRGBA/definition
Normal file
@@ -0,0 +1,2 @@
|
||||
Fixes: Implement support for 32bppRGB, 32bppRGBA and 32bppPRGBA in format converter
|
||||
Depends: windowscodecs-TIFF_Support
|
Reference in New Issue
Block a user