Dmitry Timoshkov : windowscodecs: Avoid extra conversion step BGR-> RGB when converting 32bpp BGRA to 24bpp RGB.

Alexandre Julliard julliard at winehq.org
Fri Sep 16 10:16:08 CDT 2016


Module: wine
Branch: master
Commit: 7431380e3860b58a072047751ebae80f8191937a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7431380e3860b58a072047751ebae80f8191937a

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Thu Sep 15 16:10:15 2016 -0500

windowscodecs: Avoid extra conversion step BGR->RGB when converting 32bpp BGRA to 24bpp RGB.

Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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();




More information about the wine-cvs mailing list