@@ -53,8 +53,11 @@ enum pixelformat {
53
53
format_24bppRGB ,
54
54
format_32bppGrayFloat ,
55
55
format_32bppBGR ,
56
+ format_32bppRGB ,
56
57
format_32bppBGRA ,
58
+ format_32bppRGBA ,
57
59
format_32bppPBGRA ,
60
+ format_32bppPRGBA ,
58
61
format_48bppRGB ,
59
62
format_64bppRGBA ,
60
63
format_32bppCMYK ,
@@ -858,6 +861,25 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe
858
861
}
859
862
}
860
863
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
+
861
883
static HRESULT copypixels_to_32bppBGR (struct FormatConverter * This , const WICRect * prc ,
862
884
UINT cbStride , UINT cbBufferSize , BYTE * pbBuffer , enum pixelformat source_format )
863
885
{
@@ -874,6 +896,22 @@ static HRESULT copypixels_to_32bppBGR(struct FormatConverter *This, const WICRec
874
896
}
875
897
}
876
898
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
+
877
915
static HRESULT copypixels_to_32bppPBGRA (struct FormatConverter * This , const WICRect * prc ,
878
916
UINT cbStride , UINT cbBufferSize , BYTE * pbBuffer , enum pixelformat source_format )
879
917
{
@@ -907,6 +945,39 @@ static HRESULT copypixels_to_32bppPBGRA(struct FormatConverter *This, const WICR
907
945
}
908
946
}
909
947
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
+
910
981
static HRESULT copypixels_to_24bppBGR (struct FormatConverter * This , const WICRect * prc ,
911
982
UINT cbStride , UINT cbBufferSize , BYTE * pbBuffer , enum pixelformat source_format )
912
983
{
@@ -1236,8 +1307,11 @@ static const struct pixelformatinfo supported_formats[] = {
1236
1307
{format_24bppRGB , & GUID_WICPixelFormat24bppRGB , copypixels_to_24bppRGB },
1237
1308
{format_32bppGrayFloat , & GUID_WICPixelFormat32bppGrayFloat , copypixels_to_32bppGrayFloat },
1238
1309
{format_32bppBGR , & GUID_WICPixelFormat32bppBGR , copypixels_to_32bppBGR },
1310
+ {format_32bppRGB , & GUID_WICPixelFormat32bppRGB , copypixels_to_32bppRGB },
1239
1311
{format_32bppBGRA , & GUID_WICPixelFormat32bppBGRA , copypixels_to_32bppBGRA },
1312
+ {format_32bppRGBA , & GUID_WICPixelFormat32bppRGBA , copypixels_to_32bppRGBA },
1240
1313
{format_32bppPBGRA , & GUID_WICPixelFormat32bppPBGRA , copypixels_to_32bppPBGRA },
1314
+ {format_32bppPRGBA , & GUID_WICPixelFormat32bppPRGBA , copypixels_to_32bppPRGBA },
1241
1315
{format_48bppRGB , & GUID_WICPixelFormat48bppRGB , NULL },
1242
1316
{format_64bppRGBA , & GUID_WICPixelFormat64bppRGBA , NULL },
1243
1317
{format_32bppCMYK , & GUID_WICPixelFormat32bppCMYK , NULL },
0 commit comments