X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5e5437e00bb1e42d24060e6115d2e6a042c1a93f..3cc487d140f11e26a9c4ae35ba87cc22684da65a:/src/common/image.cpp?ds=sidebyside diff --git a/src/common/image.cpp b/src/common/image.cpp index 9e4921bd87..903defa811 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -317,7 +317,7 @@ wxImage wxImage::Mirror( bool horizontally ) const for (long i = 0; i < height; i++) { target_data = data + 3*width*(height-1-i); - memcpy( target_data, source_data, 3*width ); + memcpy( target_data, source_data, (size_t)3*width ); source_data += 3*width; } } @@ -409,9 +409,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; + } } } @@ -739,9 +766,9 @@ bool wxImage::SaveFile( const wxString& filename, int type ) wxBufferedOutputStream bstream( stream ); return SaveFile(bstream, type); } - else #endif // wxUSE_STREAMS - return FALSE; + + return FALSE; } bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) @@ -754,9 +781,9 @@ bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) wxBufferedOutputStream bstream( stream ); return SaveFile(bstream, mimetype); } - else #endif // wxUSE_STREAMS - return FALSE; + + return FALSE; } bool wxImage::CanRead( const wxString &name )