]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed bitmap constructor for monochrome bitmaps
authorRobert Roebling <robert@roebling.de>
Wed, 21 Apr 1999 12:35:02 +0000 (12:35 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 21 Apr 1999 12:35:02 +0000 (12:35 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2256 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/image/image.cpp
src/gtk/bitmap.cpp
src/gtk1/bitmap.cpp

index e6b535b937c78d7aeb16b65c69c39923091d7bc7..0f1b6cf0aaa98c744bada36be2bc063c7358b31b 100644 (file)
@@ -143,6 +143,9 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
 
   dc.DrawText( "Loaded image", 30, 10 );
   if (my_square && my_square->Ok()) dc.DrawBitmap( *my_square, 30, 30 );
+  
+  wxBitmap bm( 1200, 1, 1 );
+  dc.DrawBitmap( bm, 10, 10 );
 
   dc.DrawText( "Drawn directly", 150, 10 );
   dc.SetBrush( wxBrush( "orange", wxSOLID ) );
index 0a2da3f4e9e9f314dcb908692e928e2f9d66d120..80ecdcddac6ceacd6b699c80cb13e81cf796a716 100644 (file)
@@ -105,17 +105,27 @@ wxBitmap::wxBitmap()
 wxBitmap::wxBitmap( int width, int height, int depth )
 {
     wxCHECK_RET( (width > 0) && (height > 0), _T("invalid bitmap size") )
-    wxCHECK_RET( (depth > 0) || (depth == -1), _T("invalid bitmap depth") )
-
-    m_refData = new wxBitmapRefData();
-
+    
     GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
+    if (depth == -1) depth = gdk_window_get_visual( parent )->depth;
+    
+    wxCHECK_RET( (depth ==  gdk_window_get_visual( parent )->depth) ||
+                 (depth == 1), _T("invalid bitmap depth") )
 
+    m_refData = new wxBitmapRefData();
     M_BMPDATA->m_mask = (wxMask *) NULL;
-    M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
     M_BMPDATA->m_width = width;
     M_BMPDATA->m_height = height;
-    M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
+    if (depth == 1)
+    {
+        M_BMPDATA->m_bitmap = gdk_pixmap_new( parent, width, height, 1 );
+        M_BMPDATA->m_bpp = 1;
+    }
+    else
+    {
+        M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
+        M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
+    }
 
     if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
 }
index 0a2da3f4e9e9f314dcb908692e928e2f9d66d120..80ecdcddac6ceacd6b699c80cb13e81cf796a716 100644 (file)
@@ -105,17 +105,27 @@ wxBitmap::wxBitmap()
 wxBitmap::wxBitmap( int width, int height, int depth )
 {
     wxCHECK_RET( (width > 0) && (height > 0), _T("invalid bitmap size") )
-    wxCHECK_RET( (depth > 0) || (depth == -1), _T("invalid bitmap depth") )
-
-    m_refData = new wxBitmapRefData();
-
+    
     GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
+    if (depth == -1) depth = gdk_window_get_visual( parent )->depth;
+    
+    wxCHECK_RET( (depth ==  gdk_window_get_visual( parent )->depth) ||
+                 (depth == 1), _T("invalid bitmap depth") )
 
+    m_refData = new wxBitmapRefData();
     M_BMPDATA->m_mask = (wxMask *) NULL;
-    M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
     M_BMPDATA->m_width = width;
     M_BMPDATA->m_height = height;
-    M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
+    if (depth == 1)
+    {
+        M_BMPDATA->m_bitmap = gdk_pixmap_new( parent, width, height, 1 );
+        M_BMPDATA->m_bpp = 1;
+    }
+    else
+    {
+        M_BMPDATA->m_pixmap = gdk_pixmap_new( parent, width, height, depth );
+        M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
+    }
 
     if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
 }