]> git.saurik.com Git - wxWidgets.git/commitdiff
[ 1502016 ] wxImage::ConvertToGreyscale should retain alpha channel.
authorWłodzimierz Skiba <abx@abx.art.pl>
Wed, 7 Jun 2006 17:02:08 +0000 (17:02 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Wed, 7 Jun 2006 17:02:08 +0000 (17:02 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39621 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/image.cpp

index 9e53e054f5ffe62aefd63c3d5551019242ab50ac..11e464a43c602cdc265f0103c1b227260bfd909d 100644 (file)
@@ -866,6 +866,16 @@ wxImage wxImage::ConvertToGreyscale( double lr, double lg, double lb ) const
         }
     }
 
+    // copy the alpha channel, if any
+    if (HasAlpha())
+    {
+        const size_t alphaSize = GetWidth() * GetHeight();
+        unsigned char *alpha = (unsigned char*)malloc(alphaSize);
+        memcpy(alpha, GetAlpha(), alphaSize);
+        image.InitAlpha();
+        image.SetAlpha(alpha);
+    }
+
     return image;
 }