X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d0ce3e528a41a1d2f7420888b6f360c793e5f247..887dfc146ffd1c0d64afbb2fc9ad14a4f18ba60b:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index baa5f6b8b4..a5f3c35f48 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -7,7 +7,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "image.h" #endif @@ -219,6 +219,11 @@ wxImage wxImage::Copy() const memcpy( data, GetData(), M_IMGDATA->m_width*M_IMGDATA->m_height*3 ); + // also copy the image options + wxImageRefData *imgData = (wxImageRefData *)image.m_refData; + imgData->m_optionNames = M_IMGDATA->m_optionNames; + imgData->m_optionValues = M_IMGDATA->m_optionValues; + return image; } @@ -303,9 +308,9 @@ wxImage wxImage::ShrinkBy( int xFactor , int yFactor ) const } else { - *(target_data++) = avgRed / counter ; - *(target_data++) = avgGreen / counter ; - *(target_data++) = avgBlue / counter ; + *(target_data++) = (unsigned char)(avgRed / counter); + *(target_data++) = (unsigned char)(avgGreen / counter); + *(target_data++) = (unsigned char)(avgBlue / counter); } } } @@ -1128,7 +1133,7 @@ bool wxImage::CanRead( wxInputStream &stream ) { const wxList& list = GetHandlers(); - for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() ) + for ( wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext() ) { wxImageHandler *handler=(wxImageHandler*)node->GetData(); if (handler->CanRead( stream )) @@ -1146,7 +1151,7 @@ int wxImage::GetImageCount( wxInputStream &stream, long type ) { wxList &list=GetHandlers(); - for (wxList::Node *node = list.GetFirst(); node; node = node->GetNext()) + for (wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext()) { handler=(wxImageHandler*)node->GetData(); if ( handler->CanRead(stream) ) @@ -1189,7 +1194,7 @@ bool wxImage::LoadFile( wxInputStream& stream, long type, int index ) { wxList &list=GetHandlers(); - for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() ) + for ( wxList::compatibility_iterator node = list.GetFirst(); node; node = node->GetNext() ) { handler=(wxImageHandler*)node->GetData(); if ( handler->CanRead(stream) ) @@ -1266,9 +1271,6 @@ bool wxImage::SaveFile( wxOutputStream& stream, const wxString& mimetype ) const void wxImage::AddHandler( wxImageHandler *handler ) { - // make sure that the memory will be freed at the program end - sm_handlers.DeleteContents(true); - // Check for an existing handler of the type being added. if (FindHandler( handler->GetType() ) == 0) { @@ -1290,9 +1292,6 @@ void wxImage::AddHandler( wxImageHandler *handler ) void wxImage::InsertHandler( wxImageHandler *handler ) { - // make sure that the memory will be freed at the program end - sm_handlers.DeleteContents(true); - // Check for an existing handler of the type being added. if (FindHandler( handler->GetType() ) == 0) { @@ -1313,6 +1312,7 @@ bool wxImage::RemoveHandler( const wxString& name ) if (handler) { sm_handlers.DeleteObject(handler); + delete handler; return true; } else @@ -1321,7 +1321,7 @@ bool wxImage::RemoveHandler( const wxString& name ) wxImageHandler *wxImage::FindHandler( const wxString& name ) { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler*)node->GetData(); @@ -1334,7 +1334,7 @@ wxImageHandler *wxImage::FindHandler( const wxString& name ) wxImageHandler *wxImage::FindHandler( const wxString& extension, long bitmapType ) { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler*)node->GetData(); @@ -1348,7 +1348,7 @@ wxImageHandler *wxImage::FindHandler( const wxString& extension, long bitmapType wxImageHandler *wxImage::FindHandler( long bitmapType ) { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler *)node->GetData(); @@ -1360,7 +1360,7 @@ wxImageHandler *wxImage::FindHandler( long bitmapType ) wxImageHandler *wxImage::FindHandlerMime( const wxString& mimetype ) { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler *)node->GetData(); @@ -1379,24 +1379,24 @@ void wxImage::InitStandardHandlers() void wxImage::CleanUpHandlers() { - wxNode *node = sm_handlers.GetFirst(); + wxList::compatibility_iterator node = sm_handlers.GetFirst(); while (node) { wxImageHandler *handler = (wxImageHandler *)node->GetData(); - wxNode *next = node->GetNext(); + wxList::compatibility_iterator next = node->GetNext(); delete handler; - delete node; node = next; } -} + sm_handlers.Clear(); +} wxString wxImage::GetImageExtWildcard() { wxString fmts; wxList& Handlers = wxImage::GetHandlers(); - wxNode* Node = Handlers.GetFirst(); + wxList::compatibility_iterator Node = Handlers.GetFirst(); while ( Node ) { wxImageHandler* Handler = (wxImageHandler*)Node->GetData(); @@ -1408,7 +1408,6 @@ wxString wxImage::GetImageExtWildcard() return wxT("(") + fmts + wxT(")|") + fmts; } - //----------------------------------------------------------------------------- // wxImageHandler //----------------------------------------------------------------------------- @@ -1805,8 +1804,8 @@ wxImage wxImage::Rotate(double angle, const wxPoint & centre_of_rotation, bool i w3 * *(v3++) + w4 * *(v4++)) / (w1 + w2 + w3 + w4) ); *(dst++) = (unsigned char) - ( (w1 * *(v1++) + w2 * *(v2++) + - w3 * *(v3++) + w4 * *(v4++)) / + ( (w1 * *v1 + w2 * *v2 + + w3 * *v3 + w4 * *v4) / (w1 + w2 + w3 + w4) ); } } @@ -1836,7 +1835,7 @@ wxImage wxImage::Rotate(double angle, const wxPoint & centre_of_rotation, bool i unsigned char *p = data[ys] + (3 * xs); *(dst++) = *(p++); *(dst++) = *(p++); - *(dst++) = *(p++); + *(dst++) = *p; } else {