]> git.saurik.com Git - wxWidgets.git/commitdiff
added alpha support to wxImage::Paste() (patch 1883497, bug 1831612)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Feb 2008 15:32:04 +0000 (15:32 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 9 Feb 2008 15:32:04 +0000 (15:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51617 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/image.cpp

index e739d5c71e09b2a1e92a59d1e989fa7a4a2d7fff..e4ccc1b8f322c80e49348c4d96c5e528f48eda24 100644 (file)
@@ -1283,6 +1283,26 @@ void wxImage::Paste( const wxImage &image, int x, int y )
         return;
     }
 
+    // Copy over the alpha channel from the original image
+    if ( image.HasAlpha() )
+    {
+        if ( !HasAlpha() )
+            InitAlpha();
+
+        unsigned char* source_data = image.GetAlpha() + xx + yy*image.GetWidth();
+        int source_step = image.GetWidth();
+
+        unsigned char* target_data = GetAlpha() + (x+xx) + (y+yy)*M_IMGDATA->m_width;
+        int target_step = M_IMGDATA->m_width;
+
+        for (int j = 0; j < height; j++,
+                                    source_data += source_step,
+                                    target_data += target_step)
+        {
+            memcpy( target_data, source_data, width );
+        }
+    }
+
     if (!HasMask() && image.HasMask())
     {
         unsigned char r = image.GetMaskRed();