X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c7a284c79b1f2f515abef1bc38d390b9ff81b6bc..9ef1ad0d2ccb6dee00b1adc495ce055edd27844b:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index e739d5c71e..3f25322183 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -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(); @@ -2139,13 +2159,19 @@ int wxImage::GetImageCount( wxInputStream &stream, long type ) if ( type == wxBITMAP_TYPE_ANY ) { - wxList &list=GetHandlers(); + const wxList& list = GetHandlers(); - for (wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext()) + for ( wxList::compatibility_iterator node = list.GetFirst(); + node; + node = node->GetNext() ) { - handler=(wxImageHandler*)node->GetData(); + handler = (wxImageHandler*)node->GetData(); if ( handler->CanRead(stream) ) - return handler->GetImageCount(stream); + { + const int count = handler->GetImageCount(stream); + if ( count >= 0 ) + return count; + } } @@ -2182,17 +2208,22 @@ bool wxImage::LoadFile( wxInputStream& stream, long type, int index ) if ( type == wxBITMAP_TYPE_ANY ) { - wxList &list=GetHandlers(); - - for ( wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext() ) + const wxList& list = GetHandlers(); + for ( wxList::compatibility_iterator node = list.GetFirst(); + node; + node = node->GetNext() ) { - handler=(wxImageHandler*)node->GetData(); - if ( handler->CanRead(stream) ) - return handler->LoadFile(this, stream, true/*verbose*/, index); + handler = (wxImageHandler*)node->GetData(); + if ( handler->CanRead(stream) && + handler->LoadFile(this, stream, true/*verbose*/, index) ) + { + return true; + } } wxLogWarning( _("No handler found for image type.") ); + return false; }