wx.CursorFromImage in Linux

I'm using wxPython 2.8.10.1-1 in Ubuntu 9.04 from this repository [1].
I want to set a new cursor based on a png image using the code below:

        image = wx.Image("../icons/tool_zoom.png",wx.BITMAP_TYPE_PNG)
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 0)
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 0)
        wx.SetCursor(wx.CursorFromImage(image))

The result is a cursor only with 2 colors, black & white, but the
image is colored and have transparencies. I tried too with others
image formats, like jpeg and I have the same result. In Windows it
doesn't occurs. Is there an error in my code? Is it a limitation from
Linux?

Thanks!

[1] - http://wiki.wxpython.org/InstallingOnUbuntuOrDebian

tfmoraes wrote:

I'm using wxPython 2.8.10.1-1 in Ubuntu 9.04 from this repository [1].
I want to set a new cursor based on a png image using the code below:

        image = wx.Image("../icons/tool_zoom.png",wx.BITMAP_TYPE_PNG)
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 0)
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 0)
        wx.SetCursor(wx.CursorFromImage(image))

The result is a cursor only with 2 colors, black & white, but the
image is colored and have transparencies. I tried too with others
image formats, like jpeg and I have the same result. In Windows it
doesn't occurs. Is there an error in my code? Is it a limitation from
Linux?

I think it depends on the version of X and the desktop environment.

···

--
Robin Dunn
Software Craftsman

I tried in the Fedora 11 too, and the same occurs. In both I'm using
gnome. The fedora x server version is 1.6

···

On Aug 19, 3:43 pm, Robin Dunn <ro...@alldunn.com> wrote:

tfmoraes wrote:
> I'm using wxPython 2.8.10.1-1 in Ubuntu 9.04 from this repository [1].
> I want to set a new cursor based on a png image using the code below:

> image = wx.Image("../icons/tool_zoom.png",wx.BITMAP_TYPE_PNG)
> image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 0)
> image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 0)
> wx.SetCursor(wx.CursorFromImage(image))

> The result is a cursor only with 2 colors, black & white, but the
> image is colored and have transparencies. I tried too with others
> image formats, like jpeg and I have the same result. In Windows it
> doesn't occurs. Is there an error in my code? Is it a limitation from
> Linux?

I think it depends on the version of X and the desktop environment.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

In Kde 4.2 the the problem occurs too. Could it be caused by a
compilation option?

Thanks!

···

On Aug 19, 10:01 pm, tfmoraes <totonixs...@gmail.com> wrote:

On Aug 19, 3:43 pm, Robin Dunn <ro...@alldunn.com> wrote:

> tfmoraes wrote:
> > I'm using wxPython 2.8.10.1-1 in Ubuntu 9.04 from this repository [1].
> > I want to set a new cursor based on a png image using the code below:

> > image = wx.Image("../icons/tool_zoom.png",wx.BITMAP_TYPE_PNG)
> > image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 0)
> > image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 0)
> > wx.SetCursor(wx.CursorFromImage(image))

> > The result is a cursor only with 2 colors, black & white, but the
> > image is colored and have transparencies. I tried too with others
> > image formats, like jpeg and I have the same result. In Windows it
> > doesn't occurs. Is there an error in my code? Is it a limitation from
> > Linux?

> I think it depends on the version of X and the desktop environment.

> --
> Robin Dunn
> Software Craftsmanhttp://wxPython.org

I tried in the Fedora 11 too, and the same occurs. In both I'm using
gnome. The fedora x server version is 1.6

tfmoraes wrote:

tfmoraes wrote:

I'm using wxPython 2.8.10.1-1 in Ubuntu 9.04 from this repository [1].
I want to set a new cursor based on a png image using the code below:
        image = wx.Image("../icons/tool_zoom.png",wx.BITMAP_TYPE_PNG)
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 0)
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 0)
        wx.SetCursor(wx.CursorFromImage(image))
The result is a cursor only with 2 colors, black & white, but the
image is colored and have transparencies. I tried too with others
image formats, like jpeg and I have the same result. In Windows it
doesn't occurs. Is there an error in my code? Is it a limitation from
Linux?

I think it depends on the version of X and the desktop environment.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org

I tried in the Fedora 11 too, and the same occurs. In both I'm using
gnome. The fedora x server version is 1.6

In Kde 4.2 the the problem occurs too. Could it be caused by a
compilation option?

Sorry, I must have been thinking of something else or a different platform. I just checked the code that converts a wxImage to a wxCursor in the wxGTK port and it does take the safe route and uses the GDK API [1] that makes 2-color cursors. wx calculates what the two most popular colors are in the image you give it and then passes them to the API.

[1] http://library.gnome.org/devel/gdk/unstable/gdk-Cursors.html#gdk-cursor-new-from-pixmap

A good enhancement here would be to use gdk_display_supports_cursor_color() and gdk_display_supports_cursor_alpha() to find out what the capabilities of the display are and then react accordingly when actually creating the cursor. If anybody feels like working on this patch please do and submit it as a ticket to wxTrac.

···

On Aug 19, 10:01 pm, tfmoraes <totonixs...@gmail.com> wrote:

On Aug 19, 3:43 pm, Robin Dunn <ro...@alldunn.com> wrote:

--
Robin Dunn
Software Craftsman