From 49849fadb818c88fa75a6dc8c80f005fe1f5aa78 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 29 Aug 2000 18:18:51 +0000 Subject: [PATCH] Implemted wxImage::Paste() for transparent images. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8213 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/image.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/common/image.cpp b/src/common/image.cpp index edda6c960f..1aa5903ad4 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -406,9 +406,36 @@ void wxImage::Paste( const wxImage &image, int x, int y ) source_data += source_step; target_data += target_step; } + return; } - else + + if (!HasMask() && image.HasMask()) { + unsigned char r = image.GetMaskRed(); + unsigned char g = image.GetMaskGreen(); + unsigned char b = image.GetMaskBlue(); + + width *= 3; + unsigned char* source_data = image.GetData() + xx*3 + yy*3*image.GetWidth(); + int source_step = image.GetWidth()*3; + + unsigned char* target_data = GetData() + (x+xx)*3 + (y+yy)*3*M_IMGDATA->m_width; + int target_step = M_IMGDATA->m_width*3; + + for (int j = 0; j < height; j++) + { + for (int i = 0; i < width; i+=3) + { + if ((source_data[i] != r) && + (source_data[i+1] != g) && + (source_data[i+2] != b)) + { + memcpy( target_data+i, source_data+i, 3 ); + } + } + source_data += source_step; + target_data += target_step; + } } }