if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
}
+wxBitmap::wxBitmap( const char **bits )
+{
+ wxCHECK_RET( bits != NULL, "invalid bitmap data" )
+
+ m_refData = new wxBitmapRefData();
+
+ GdkBitmap *mask = (GdkBitmap*) NULL;
+ GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
+
+ M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
+
+ 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 = gdk_window_get_visual( parent )->depth; // ?
+ if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
+}
+
wxBitmap::wxBitmap( char **bits )
{
wxCHECK_RET( bits != NULL, "invalid bitmap data" )
int wxBitmap::GetHeight(void) const
{
- if (!Ok())
- {
- wxFAIL_MSG( "invalid bitmap" );
- return -1;
- }
+ wxCHECK_MSG( Ok(), -1, "invalid bitmap" );
return M_BMPDATA->m_height;
}
int wxBitmap::GetWidth(void) const
{
- if (!Ok())
- {
- wxFAIL_MSG( "invalid bitmap" );
- return -1;
- }
+ wxCHECK_MSG( Ok(), -1, "invalid bitmap" );
return M_BMPDATA->m_width;
}
int wxBitmap::GetDepth(void) const
{
- if (!Ok())
- {
- wxFAIL_MSG( "invalid bitmap" );
- return -1;
- }
+ wxCHECK_MSG( Ok(), -1, "invalid bitmap" );
return M_BMPDATA->m_bpp;
}
wxMask *wxBitmap::GetMask(void) const
{
- if (!Ok())
- {
- wxFAIL_MSG( "invalid bitmap" );
- return (wxMask *) NULL;
- }
+ wxCHECK_MSG( Ok(), (wxMask *) NULL, "invalid bitmap" );
return M_BMPDATA->m_mask;
}
void wxBitmap::SetMask( wxMask *mask )
{
- if (!Ok())
- {
- wxFAIL_MSG( "invalid bitmap" );
- return;
- }
+ wxCHECK_RET( Ok(), "invalid bitmap" );
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) )
{
- if (!Ok())
- {
- wxFAIL_MSG( "invalid bitmap" );
- return FALSE;
- }
+ wxCHECK_MSG( Ok(), FALSE, "invalid bitmap" );
if (type == wxBITMAP_TYPE_PNG)
{
wxPalette *wxBitmap::GetPalette(void) const
{
if (!Ok()) return (wxPalette *) NULL;
+
return M_BMPDATA->m_palette;
}
GdkPixmap *wxBitmap::GetPixmap(void) const
{
- if (!Ok())
- {
- wxFAIL_MSG( "invalid bitmap" );
- return (GdkPixmap *) NULL;
- }
+ wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, "invalid bitmap" );
return M_BMPDATA->m_pixmap;
}
GdkBitmap *wxBitmap::GetBitmap(void) const
{
- if (!Ok())
- {
- wxFAIL_MSG( "invalid bitmap" );
- return (GdkBitmap *) NULL;
- }
+ wxCHECK_MSG( Ok(), (GdkBitmap *) NULL, "invalid bitmap" );
return M_BMPDATA->m_bitmap;
}
{
wxImage image;
- if (!Ok())
- {
- wxFAIL_MSG( "invalid bitmap" );
- return image;
- }
+ wxCHECK_MSG( Ok(), image, "invalid bitmap" );
GdkImage *gdk_image = gdk_image_get( M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height );