From: Paul Cornett Date: Thu, 3 Jan 2008 06:58:11 +0000 (+0000) Subject: fix for last commit: didn't work if mask was white X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e60f8377beb9c1f96689383ee9642de20168cc21 fix for last commit: didn't work if mask was white git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51003 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/cursor.cpp b/src/gtk/cursor.cpp index 67148c8a74..c8e710bc96 100644 --- a/src/gtk/cursor.cpp +++ b/src/gtk/cursor.cpp @@ -201,8 +201,29 @@ wxCursor::wxCursor( const wxImage & image ) return; } + unsigned long keyMaskColor = 0; + GdkPixmap* mask; + if (bHasMask) + { + keyMaskColor = wxImageHistogram::MakeKey( + image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue()); + // get mask before image is modified + wxBitmap bitmap(image, 1); + mask = bitmap.GetMask()->GetBitmap(); + g_object_ref(mask); + } + else + { + const int size = ((w + 7) / 8) * h; + char* bits = new char[size]; + memset(bits, 0xff, size); + mask = gdk_bitmap_create_from_data( + wxGetRootWindow()->window, bits, w, h); + delete[] bits; + } + // modify image so wxBitmap can be used to convert to pixmap - image_copy.UnShare(); + image_copy.SetMask(false); int i, j; wxByte* data = image_copy.GetData(); for (j = 0; j < h; j++) @@ -219,28 +240,8 @@ wxCursor::wxCursor( const wxImage & image ) } } } - wxBitmap bitmap(image_copy, 1); - unsigned long keyMaskColor = 0; - GdkPixmap* mask; - if (bHasMask) - { - keyMaskColor = wxImageHistogram::MakeKey( - image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue()); - mask = bitmap.GetMask()->GetBitmap(); - g_object_ref(mask); - } - else - { - const int size = ((w + 7) / 8) * h; - char* bits = new char[size]; - memset(bits, 0xff, size); - mask = gdk_bitmap_create_from_data( - bitmap.GetPixmap(), bits, w, h); - delete[] bits; - } - // find the most frequent color(s) wxImageHistogram histogram; image.ComputeHistogram(histogram);