+ // Try to save the bitmap via wxImage handlers:
+ {
+ wxImage image = ConvertToImage();
+ if (image.Ok()) return image.SaveFile( name, type );
+ }
+
+ return false;
+}
+
+bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
+{
+ UnRef();
+
+ if (!wxFileExists(name))
+ return false;
+
+ GdkVisual *visual = wxTheApp->GetGdkVisual();
+
+ if (type == wxBITMAP_TYPE_XPM)
+ {
+ m_refData = new wxBitmapRefData();
+
+ GdkBitmap *mask = (GdkBitmap*) NULL;
+
+ M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm
+ (
+ wxGetRootWindow()->window,
+ &mask,
+ NULL,
+ name.fn_str()
+ );
+
+ if (mask)
+ {
+ M_BMPDATA->m_mask = new wxMask();
+ M_BMPDATA->m_mask->m_bitmap = mask;
+ }
+
+ gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
+
+ M_BMPDATA->m_bpp = visual->depth;
+ }
+ else // try if wxImage can load it
+ {
+ wxImage image;
+ if ( !image.LoadFile( name, type ) || !image.Ok() )
+ return false;
+
+ *this = wxBitmap(image);
+ }
+
+ return true;
+}
+
+#if wxUSE_PALETTE
+wxPalette *wxBitmap::GetPalette() const
+{
+ if (!Ok())
+ return (wxPalette *) NULL;
+
+ return M_BMPDATA->m_palette;
+}
+
+void wxBitmap::SetPalette(const wxPalette& WXUNUSED(palette))
+{
+ // TODO
+}
+#endif // wxUSE_PALETTE
+
+void wxBitmap::SetHeight( int height )
+{
+ if (!m_refData)
+ m_refData = new wxBitmapRefData();
+
+ M_BMPDATA->m_height = height;
+}
+
+void wxBitmap::SetWidth( int width )
+{
+ if (!m_refData)
+ m_refData = new wxBitmapRefData();
+
+ M_BMPDATA->m_width = width;
+}
+
+void wxBitmap::SetDepth( int depth )
+{
+ if (!m_refData)
+ m_refData = new wxBitmapRefData();
+
+ M_BMPDATA->m_bpp = depth;
+}
+
+void wxBitmap::SetPixmap( GdkPixmap *pixmap )
+{
+ if (!m_refData)
+ m_refData = new wxBitmapRefData();
+
+ M_BMPDATA->m_pixmap = pixmap;
+}
+
+void wxBitmap::SetBitmap( GdkPixmap *bitmap )
+{
+ if (!m_refData)
+ m_refData = new wxBitmapRefData();
+
+ M_BMPDATA->m_bitmap = bitmap;
+}
+
+GdkPixmap *wxBitmap::GetPixmap() const
+{
+ wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") );
+
+ return M_BMPDATA->m_pixmap;
+}
+
+bool wxBitmap::HasPixmap() const
+{
+ wxCHECK_MSG( Ok(), false, wxT("invalid bitmap") );
+
+ return M_BMPDATA->m_pixmap != NULL;
+}
+
+GdkBitmap *wxBitmap::GetBitmap() const
+{
+ wxCHECK_MSG( Ok(), (GdkBitmap *) NULL, wxT("invalid bitmap") );
+
+ return M_BMPDATA->m_bitmap;
+}
+
+void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
+{
+ return NULL;
+}
+
+void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data))
+{
+}
+
+
+bool wxBitmap::HasAlpha() const
+{
+ return false;
+}
+
+void wxBitmap::UseAlpha()
+{
+}
+
+//-----------------------------------------------------------------------------
+// wxBitmapHandler
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler,wxBitmapHandlerBase)
+
+wxBitmapHandler::~wxBitmapHandler()
+{
+}
+
+bool wxBitmapHandler::Create(wxBitmap * WXUNUSED(bitmap),
+ void * WXUNUSED(data),
+ long WXUNUSED(type),
+ int WXUNUSED(width),
+ int WXUNUSED(height),
+ int WXUNUSED(depth))
+{
+ wxFAIL_MSG( _T("not implemented") );
+
+ return false;
+}
+
+bool wxBitmapHandler::LoadFile(wxBitmap * WXUNUSED(bitmap),
+ const wxString& WXUNUSED(name),
+ long WXUNUSED(flags),
+ int WXUNUSED(desiredWidth),
+ int WXUNUSED(desiredHeight))
+{
+ wxFAIL_MSG( _T("not implemented") );
+
+ return false;
+}
+
+bool wxBitmapHandler::SaveFile(const wxBitmap * WXUNUSED(bitmap),
+ const wxString& WXUNUSED(name),
+ int WXUNUSED(type),
+ const wxPalette * WXUNUSED(palette))
+{
+ wxFAIL_MSG( _T("not implemented") );
+
+ return false;
+}
+
+/* static */ void wxBitmap::InitStandardHandlers()
+{
+ // TODO: Insert handler based on GdkPixbufs handler later
+}