#include "wx/filefn.h"
#include "wx/image.h"
-#include "gdk/gdk.h"
-#include "gdk/gdkprivate.h"
-#include "gdk/gdkx.h"
+#include <gdk/gdk.h>
+#include <gdk/gdkprivate.h>
+#include <gdk/gdkx.h>
//-----------------------------------------------------------------------------
// wxMask
wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour )
{
+ m_bitmap = (GdkBitmap *) NULL;
Create( bitmap, colour );
}
wxMask::wxMask( const wxBitmap& bitmap, int paletteIndex )
{
+ m_bitmap = (GdkBitmap *) NULL;
Create( bitmap, paletteIndex );
}
wxMask::wxMask( const wxBitmap& bitmap )
{
+ m_bitmap = (GdkBitmap *) NULL;
Create( bitmap );
}
wxMask::~wxMask()
{
- if (m_bitmap) gdk_bitmap_unref( m_bitmap );
+ if (m_bitmap)
+ gdk_bitmap_unref( m_bitmap );
}
bool wxMask::Create( const wxBitmap& WXUNUSED(bitmap),
{
wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") );
- if (type == wxBITMAP_TYPE_PNG)
+ // Try to save the bitmap via wxImage handlers:
{
wxImage image( *this );
if (image.Ok()) return image.SaveFile( name, type );
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
}
- else if (type == wxBITMAP_TYPE_PNG)
+ else // try if wxImage can load it
{
wxImage image;
- image.LoadFile( name, type );
+ if (!image.LoadFile( name, type )) return FALSE;
if (image.Ok()) *this = image.ConvertToBitmap();
+ else return FALSE;
}
- else if (type == wxBITMAP_TYPE_BMP)
- {
- wxImage image;
- image.LoadFile( name, type );
- if (image.Ok()) *this = image.ConvertToBitmap();
- }
- else
- return FALSE;
return TRUE;
}