// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "image.h"
#endif
#include "wx/intl.h"
#include "wx/module.h"
#include "wx/hash.h"
+#include "wx/utils.h"
// For memcpy
#include <string.h>
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;
}
}
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);
}
}
}
{
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 ))
{
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) )
{
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) )
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)
{
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)
{
if (handler)
{
sm_handlers.DeleteObject(handler);
+ delete handler;
return true;
}
else
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();
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();
wxImageHandler *wxImage::FindHandler( long bitmapType )
{
- wxNode *node = sm_handlers.GetFirst();
+ wxList::compatibility_iterator node = sm_handlers.GetFirst();
while (node)
{
wxImageHandler *handler = (wxImageHandler *)node->GetData();
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();
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();
return wxT("(") + fmts + wxT(")|") + fmts;
}
-
//-----------------------------------------------------------------------------
// wxImageHandler
//-----------------------------------------------------------------------------
#endif // wxUSE_STREAMS
-
-
-//-----------------------------------------------------------------------------
-// Deprecated wxBitmap conversion routines
-//-----------------------------------------------------------------------------
-
-#if WXWIN_COMPATIBILITY_2_2 && wxUSE_GUI
-
-#ifdef __WXGTK__
-wxBitmap wxImage::ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue ) const
-{
- wxImage mono = this->ConvertToMono( red, green, blue );
- wxBitmap bitmap( mono, 1 );
- return bitmap;
-}
-#endif
-
-wxBitmap wxImage::ConvertToBitmap() const
-{
- wxBitmap bitmap( *this );
- return bitmap;
-}
-
-wxImage::wxImage( const wxBitmap &bitmap )
-{
- *this = bitmap.ConvertToImage();
-}
-
-#endif // WXWIN_COMPATIBILITY_2_2 && wxUSE_GUI
-
-
// ----------------------------------------------------------------------------
// image histogram stuff
// ----------------------------------------------------------------------------