X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ba938d07881b247404ef71fb1f4d19ef29ecc99f..249803fbcd1f73040e4b5457e341d8db2e5cb66e:/src/gtk/bitmap.cpp diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index c5ebe0fabd..fcc84f7786 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -18,6 +18,7 @@ #include "wx/icon.h" #include "wx/math.h" #include "wx/image.h" + #include "wx/colour.h" #endif #include "wx/rawbmp.h" @@ -84,7 +85,7 @@ bool wxMask::Create( const wxBitmap& bitmap, // one bit per pixel, each row starts on a byte boundary const size_t out_size = size_t((w + 7) / 8) * unsigned(h); wxByte* out = new wxByte[out_size]; - // set bits are white + // set bits are unmasked memset(out, 0xff, out_size); unsigned bit_index = 0; if (bitmap.HasPixbuf()) @@ -109,8 +110,11 @@ bool wxMask::Create( const wxBitmap& bitmap, { GdkImage* image = gdk_drawable_get_image(bitmap.GetPixmap(), 0, 0, w, h); GdkColormap* colormap = gdk_image_get_colormap(image); - guint32 mask_pixel = 1; - if (colormap != NULL) + guint32 mask_pixel; + if (colormap == NULL) + // mono bitmap, white is pixel value 0 + mask_pixel = guint32(colour.Red() != 255 || colour.Green() != 255 || colour.Blue() != 255); + else { wxColor c(colour); c.CalcPixel(colormap); @@ -181,7 +185,7 @@ class wxBitmapRefData: public wxObjectRefData { public: wxBitmapRefData(); - ~wxBitmapRefData(); + virtual ~wxBitmapRefData(); GdkPixmap *m_pixmap; GdkPixbuf *m_pixbuf; @@ -493,7 +497,7 @@ bool wxBitmap::CreateFromImageAsPixmap(const wxImage& image, int depth) // one bit per pixel, each row starts on a byte boundary const size_t out_size = size_t((w + 7) / 8) * unsigned(h); wxByte* out = new wxByte[out_size]; - // set bits are white + // set bits are black memset(out, 0xff, out_size); const wxByte* in = image.GetData(); unsigned bit_index = 0; @@ -577,7 +581,7 @@ bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image) wxASSERT( gdk_pixbuf_get_width(pixbuf) == width ); wxASSERT( gdk_pixbuf_get_height(pixbuf) == height ); - SetDepth(wxTheApp->GetGdkVisual()->depth); + SetDepth(32); SetPixbuf(pixbuf); // Copy the data: @@ -641,10 +645,9 @@ wxImage wxBitmap::ConvertToImage() const { GdkPixmap* pixmap = GetPixmap(); GdkPixmap* pixmap_invert = NULL; -#if 0 if (GetDepth() == 1) { - // mono bitmaps are inverted + // mono bitmaps are inverted, i.e. 0 is white pixmap_invert = gdk_pixmap_new(pixmap, w, h, 1); GdkGC* gc = gdk_gc_new(pixmap_invert); gdk_gc_set_function(gc, GDK_COPY_INVERT); @@ -652,7 +655,6 @@ wxImage wxBitmap::ConvertToImage() const g_object_unref(gc); pixmap = pixmap_invert; } -#endif // create a pixbuf which shares data with the wxImage GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( data, GDK_COLORSPACE_RGB, false, 8, w, h, 3 * w, NULL, NULL);