Skip to content

Commit 72f375e

Browse files
committed
windowscodecs: Support 32bpp formats and SupportsTransparency flag
This is a combination of these patches in wine-staging by Dmitry Timoshkov: windowscodecs: Add support for 32bppRGB, 32bppRGBA and 32bppPRGBA to format converter. windowscodecs: Fix the SupportsTransparency flag value for various pixel formats.
1 parent 7af2914 commit 72f375e

File tree

2 files changed

+114
-4
lines changed

2 files changed

+114
-4
lines changed

dlls/windowscodecs/converter.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ enum pixelformat {
5353
format_24bppRGB,
5454
format_32bppGrayFloat,
5555
format_32bppBGR,
56+
format_32bppRGB,
5657
format_32bppBGRA,
58+
format_32bppRGBA,
5759
format_32bppPBGRA,
60+
format_32bppPRGBA,
5861
format_48bppRGB,
5962
format_64bppRGBA,
6063
format_32bppCMYK,
@@ -858,6 +861,25 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
858861
}
859862
}
860863

864+
static HRESULT copypixels_to_32bppRGBA(struct FormatConverter *This, const WICRect *prc,
865+
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
866+
{
867+
HRESULT hr;
868+
869+
switch (source_format)
870+
{
871+
case format_32bppRGBA:
872+
if (prc)
873+
return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
874+
return S_OK;
875+
default:
876+
hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
877+
if (SUCCEEDED(hr) && prc)
878+
reverse_bgr8(4, pbBuffer, prc->Width, prc->Height, cbStride);
879+
return hr;
880+
}
881+
}
882+
861883
static HRESULT copypixels_to_32bppBGR(struct FormatConverter *This, const WICRect *prc,
862884
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
863885
{
@@ -874,6 +896,22 @@ static HRESULT copypixels_to_32bppBGR(struct FormatConverter *This, const WICRec
874896
}
875897
}
876898

899+
static HRESULT copypixels_to_32bppRGB(struct FormatConverter *This, const WICRect *prc,
900+
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
901+
{
902+
switch (source_format)
903+
{
904+
case format_32bppRGB:
905+
case format_32bppRGBA:
906+
case format_32bppPRGBA:
907+
if (prc)
908+
return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
909+
return S_OK;
910+
default:
911+
return copypixels_to_32bppRGBA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
912+
}
913+
}
914+
877915
static HRESULT copypixels_to_32bppPBGRA(struct FormatConverter *This, const WICRect *prc,
878916
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
879917
{
@@ -907,6 +945,39 @@ static HRESULT copypixels_to_32bppPBGRA(struct FormatConverter *This, const WICR
907945
}
908946
}
909947

948+
static HRESULT copypixels_to_32bppPRGBA(struct FormatConverter *This, const WICRect *prc,
949+
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
950+
{
951+
HRESULT hr;
952+
953+
switch (source_format)
954+
{
955+
case format_32bppPRGBA:
956+
if (prc)
957+
return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
958+
return S_OK;
959+
default:
960+
hr = copypixels_to_32bppRGBA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
961+
if (SUCCEEDED(hr) && prc)
962+
{
963+
INT x, y;
964+
965+
for (y=0; y<prc->Height; y++)
966+
for (x=0; x<prc->Width; x++)
967+
{
968+
BYTE alpha = pbBuffer[cbStride*y+4*x+3];
969+
if (alpha != 255)
970+
{
971+
pbBuffer[cbStride*y+4*x] = pbBuffer[cbStride*y+4*x] * alpha / 255;
972+
pbBuffer[cbStride*y+4*x+1] = pbBuffer[cbStride*y+4*x+1] * alpha / 255;
973+
pbBuffer[cbStride*y+4*x+2] = pbBuffer[cbStride*y+4*x+2] * alpha / 255;
974+
}
975+
}
976+
}
977+
return hr;
978+
}
979+
}
980+
910981
static HRESULT copypixels_to_24bppBGR(struct FormatConverter *This, const WICRect *prc,
911982
UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
912983
{
@@ -1236,8 +1307,11 @@ static const struct pixelformatinfo supported_formats[] = {
12361307
{format_24bppRGB, &GUID_WICPixelFormat24bppRGB, copypixels_to_24bppRGB},
12371308
{format_32bppGrayFloat, &GUID_WICPixelFormat32bppGrayFloat, copypixels_to_32bppGrayFloat},
12381309
{format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR},
1310+
{format_32bppRGB, &GUID_WICPixelFormat32bppRGB, copypixels_to_32bppRGB},
12391311
{format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA},
1312+
{format_32bppRGBA, &GUID_WICPixelFormat32bppRGBA, copypixels_to_32bppRGBA},
12401313
{format_32bppPBGRA, &GUID_WICPixelFormat32bppPBGRA, copypixels_to_32bppPBGRA},
1314+
{format_32bppPRGBA, &GUID_WICPixelFormat32bppPRGBA, copypixels_to_32bppPRGBA},
12411315
{format_48bppRGB, &GUID_WICPixelFormat48bppRGB, NULL},
12421316
{format_64bppRGBA, &GUID_WICPixelFormat64bppRGBA, NULL},
12431317
{format_32bppCMYK, &GUID_WICPixelFormat32bppCMYK, NULL},

dlls/windowscodecs/regsvr.c

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,8 +1454,11 @@ static GUID const * const converter_formats[] = {
14541454
&GUID_WICPixelFormat24bppBGR,
14551455
&GUID_WICPixelFormat24bppRGB,
14561456
&GUID_WICPixelFormat32bppBGR,
1457+
&GUID_WICPixelFormat32bppRGB,
14571458
&GUID_WICPixelFormat32bppBGRA,
1459+
&GUID_WICPixelFormat32bppRGBA,
14581460
&GUID_WICPixelFormat32bppPBGRA,
1461+
&GUID_WICPixelFormat32bppPRGBA,
14591462
&GUID_WICPixelFormat32bppGrayFloat,
14601463
&GUID_WICPixelFormat48bppRGB,
14611464
&GUID_WICPixelFormat64bppRGBA,
@@ -1759,7 +1762,7 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
17591762
1, /* channel count */
17601763
channel_masks_1bit,
17611764
WICPixelFormatNumericRepresentationIndexed,
1762-
1
1765+
0
17631766
},
17641767
{ &GUID_WICPixelFormat2bppIndexed,
17651768
"The Wine Project",
@@ -1770,7 +1773,7 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
17701773
1, /* channel count */
17711774
channel_masks_2bit,
17721775
WICPixelFormatNumericRepresentationIndexed,
1773-
1
1776+
0
17741777
},
17751778
{ &GUID_WICPixelFormat4bppIndexed,
17761779
"The Wine Project",
@@ -1781,7 +1784,7 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
17811784
1, /* channel count */
17821785
channel_masks_4bit,
17831786
WICPixelFormatNumericRepresentationIndexed,
1784-
1
1787+
0
17851788
},
17861789
{ &GUID_WICPixelFormat8bppIndexed,
17871790
"The Wine Project",
@@ -1792,7 +1795,7 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
17921795
1, /* channel count */
17931796
channel_masks_8bit,
17941797
WICPixelFormatNumericRepresentationIndexed,
1795-
1
1798+
0
17961799
},
17971800
{ &GUID_WICPixelFormatBlackWhite,
17981801
"The Wine Project",
@@ -1915,6 +1918,17 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
19151918
WICPixelFormatNumericRepresentationUnsignedInteger,
19161919
0
19171920
},
1921+
{ &GUID_WICPixelFormat32bppRGB,
1922+
"The Wine Project",
1923+
"32bpp RGB",
1924+
NULL, /* no version */
1925+
&GUID_VendorMicrosoft,
1926+
32, /* bitsperpixel */
1927+
3, /* channel count */
1928+
channel_masks_8bit,
1929+
WICPixelFormatNumericRepresentationUnsignedInteger,
1930+
0
1931+
},
19181932
{ &GUID_WICPixelFormat32bppBGRA,
19191933
"The Wine Project",
19201934
"32bpp BGRA",
@@ -1926,6 +1940,17 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
19261940
WICPixelFormatNumericRepresentationUnsignedInteger,
19271941
1
19281942
},
1943+
{ &GUID_WICPixelFormat32bppRGBA,
1944+
"The Wine Project",
1945+
"32bpp RGBA",
1946+
NULL, /* no version */
1947+
&GUID_VendorMicrosoft,
1948+
32, /* bitsperpixel */
1949+
4, /* channel count */
1950+
channel_masks_8bit,
1951+
WICPixelFormatNumericRepresentationUnsignedInteger,
1952+
1
1953+
},
19291954
{ &GUID_WICPixelFormat32bppPBGRA,
19301955
"The Wine Project",
19311956
"32bpp PBGRA",
@@ -1937,6 +1962,17 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
19371962
WICPixelFormatNumericRepresentationUnsignedInteger,
19381963
1
19391964
},
1965+
{ &GUID_WICPixelFormat32bppPRGBA,
1966+
"The Wine Project",
1967+
"32bpp PRGBA",
1968+
NULL, /* no version */
1969+
&GUID_VendorMicrosoft,
1970+
32, /* bitsperpixel */
1971+
4, /* channel count */
1972+
channel_masks_8bit,
1973+
WICPixelFormatNumericRepresentationUnsignedInteger,
1974+
1
1975+
},
19401976
{ &GUID_WICPixelFormat48bppRGB,
19411977
"The Wine Project",
19421978
"48bpp RGB",

0 commit comments

Comments
 (0)