unsigned char green = colour.Green();
unsigned char blue = colour.Blue();
- GdkVisual *visual = gdk_visual_get_system();
+ GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
+ wxASSERT( visual );
+
int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp == 15)
wxBitmap::wxBitmap( int width, int height, int depth )
{
- wxCHECK_RET( (width > 0) && (height > 0), wxT("invalid bitmap size") )
+ Create( width, height, depth );
- if (depth == -1) depth = gdk_window_get_visual( wxRootWindow->window )->depth;
+ if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
+}
+
+bool wxBitmap::Create( int width, int height, int depth )
+{
+ UnRef();
- wxCHECK_RET( (depth == gdk_window_get_visual( wxRootWindow->window )->depth) ||
- (depth == 1), wxT("invalid bitmap depth") )
+ wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") )
+
+ GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
+ wxASSERT( visual );
+
+ if (depth == -1) depth = visual->depth;
+
+ wxCHECK_MSG( (depth == visual->depth) ||
+ (depth == 1), FALSE, wxT("invalid bitmap depth") )
m_refData = new wxBitmapRefData();
M_BMPDATA->m_mask = (wxMask *) NULL;
else
{
M_BMPDATA->m_pixmap = gdk_pixmap_new( wxRootWindow->window, width, height, depth );
- M_BMPDATA->m_bpp = gdk_window_get_visual( wxRootWindow->window )->depth;
+ M_BMPDATA->m_bpp = visual->depth;
}
- if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
+ return Ok();
}
-
bool wxBitmap::CreateFromXpm( const char **bits )
{
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
+ GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
+ wxASSERT( visual );
+
m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL;
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
- M_BMPDATA->m_bpp = gdk_window_get_visual( wxRootWindow->window )->depth; // ?
+ M_BMPDATA->m_bpp = visual->depth; // ?
+
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
return TRUE;
if (!wxFileExists(name)) return FALSE;
+ GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window );
+ wxASSERT( visual );
+
if (type == wxBITMAP_TYPE_XPM)
{
m_refData = new wxBitmapRefData();
}
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
- M_BMPDATA->m_bpp = gdk_window_get_visual( wxRootWindow->window )->depth;
+
+ M_BMPDATA->m_bpp = visual->depth;
}
else // try if wxImage can load it
{