- int w = image.GetWidth() ;
- int h = image.GetHeight();
- bool bHasMask = image.HasMask();
- int hotSpotX, hotSpotY;
- GetHotSpot(image, hotSpotX, hotSpotY);
- m_refData = new wxCursorRefData;
- wxImage image_copy(image);
-
- GdkDisplay* display = gdk_drawable_get_display(wxGetRootWindow()->window);
- if (gdk_display_supports_cursor_color(display))
- {
- if (!image.HasAlpha())
- {
- // add alpha, so wxBitmap will convert to pixbuf format
- image_copy.InitAlpha();
- }
- wxBitmap bitmap(image_copy);
- wxASSERT(bitmap.HasPixbuf());
- M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixbuf
- (
- display,
- bitmap.GetPixbuf(),
- hotSpotX, hotSpotY
- );
- 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.SetMask(false);
- int i, j;
- wxByte* data = image_copy.GetData();
- for (j = 0; j < h; j++)
+ const int w = image.GetWidth();
+ const int h = image.GetHeight();
+ const guchar* alpha = image.GetAlpha();
+ const bool hasMask = image.HasMask();
+ int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
+ int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
+ if (hotSpotX < 0 || hotSpotX > w) hotSpotX = 0;
+ if (hotSpotY < 0 || hotSpotY > h) hotSpotY = 0;
+ GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data(image.GetData(), GDK_COLORSPACE_RGB, false, 8, w, h, w * 3, NULL, NULL);
+ if (alpha || hasMask)