32bit cursors Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Vexator
I live to help wx-kind
I live to help wx-kind
Posts: 187
Joined: Sun Jan 30, 2005 2:50 pm
Location: Heidelberg, Germany

32bit cursors

Post by Vexator »

ok now that i could manage to use 32bit bitmaps on toolbars, i'd like to do the same for cursors. i use png files with alpha channels for transparency, load them into wxImages and convert these to wxbitmaps.
i want to do the same for cursors. you can create a cursor directly from a wximage, but the docs say:
wxCursor(const wxImage& image)
Constructs a cursor from a wxImage. The cursor is monochrome, colors with the RGB elements all greater than 127 will be foreground, colors less than this background. The mask (if any) will be used as transparent.
uh?! so how can i create 32bit cursors with wx (at least on winxp) to be able to create cursors with soft transitions and shadows?

thanks in advance! :D
Windows 7 Pro
Visual Studio 2010
wxWidgets 2.9.3
Jamie
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Wed Mar 30, 2005 10:56 pm

Post by Jamie »

Works for me on XP. The docs are wrong.
Vexator
I live to help wx-kind
I live to help wx-kind
Posts: 187
Joined: Sun Jan 30, 2005 2:50 pm
Location: Heidelberg, Germany

Post by Vexator »

yes, i got a 32bit png file working as a cursor :) but the alpha mask is not being used, so the cursor is just displayed as a square.
Windows 7 Pro
Visual Studio 2010
wxWidgets 2.9.3
Avi
Super wx Problem Solver
Super wx Problem Solver
Posts: 398
Joined: Mon Aug 30, 2004 9:27 pm
Location: Tel-Aviv, Israel

Post by Avi »

Vexator wrote:yes, i got a 32bit png file working as a cursor :) but the alpha mask is not being used, so the cursor is just displayed as a square.
Maybe it has something to do with the way you load the wxImage from the file? (making sure the alpha channel is used?)
Jindrich.Novak
Knows some wx things
Knows some wx things
Posts: 37
Joined: Wed Feb 09, 2005 7:31 am
Location: Liberec, Czech Republic

alpha in cursors on windows

Post by Jindrich.Novak »

I dont know
but in windows cursors is not alpha, but some grey color (see visual c icon editor, BB icon editor)

Jindrich
Vexator
I live to help wx-kind
I live to help wx-kind
Posts: 187
Joined: Sun Jan 30, 2005 2:50 pm
Location: Heidelberg, Germany

Post by Vexator »

Maybe it has something to do with the way you load the wxImage from the file? (making sure the alpha channel is used?)
it's the same code and file i use for my toolbar icons, and there it works..
Windows 7 Pro
Visual Studio 2010
wxWidgets 2.9.3
Jamie
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Wed Mar 30, 2005 10:56 pm

Post by Jamie »

Adding this to the minimal sample:

Code: Select all

#include <wx/image.h>

    wxImage::AddHandler(new wxPNGHandler);
    wxImage im(_T("cursor7oa.png"));
    wxCursor c(im);
    SetCursor(c);
using this png:

http://img80.imageshack.us/img80/4566/cursor7oa.png

works fine for me.
Vexator
I live to help wx-kind
I live to help wx-kind
Posts: 187
Joined: Sun Jan 30, 2005 2:50 pm
Location: Heidelberg, Germany

Post by Vexator »

i found the problem.. the cursors have to be 32x32, at least on win32. mine was 16x16.. thanks! :D
Windows 7 Pro
Visual Studio 2010
wxWidgets 2.9.3
Post Reply