X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c7deb4ab804ff6e7fd3eda9174556164e9da766e..32b9d9ff9773e2e41c9147174359f836822f2d7d:/src/gtk/bitmap.cpp?ds=sidebyside diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 3eca0eb586..a14de5ece0 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -84,7 +84,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 +109,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); @@ -493,7 +496,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 +580,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: @@ -643,7 +646,7 @@ wxImage wxBitmap::ConvertToImage() const GdkPixmap* pixmap_invert = NULL; 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);