Custom Mouse Cursor Inquiries..
Hello!
Is it possible to create a custom cursor using an RGBA png file (or any other RGBA image file type)?
I have used Toolkit's createCustomCursor method, but it did not "render" my png file correctly.
Specifically it "rendered" the transparent colors as opaque (which means that it probably ignored the alpha channel of each pixel).
I have looked in the Toolkit class source code but I couldn't figure out if it is the createCustomCursor method to blame..
Any ideas?
It would be nice to integrate professional looking cursors in java applications (eg. RGBA, animated, etc.)
Thanks for bothering.
Cheers!
# 2
Thanks for your reply Rodney.
Platform is LoseXP : ), but it shouldn't matter.
Let me try to explain my "problem" in a better way.
I have no problem with simple transparency.
I have problems with colored transparency.
For example, imagine a glass painted red. It still is transparent, though in a red point of view : )..
That's the effect I want to create. As far as I am concerned gifs do not support colored transparency (RGBA color model).
That's why I use png files.
This is the code I use:
Cursor curs = null;
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image cursorImage = new ImageIcon(getClass().getResource("/art/cur.png")).getImage();
curs = toolkit.createCustomCursor(cursorImage, new Point(0, 0),"cur");
setCursor(curs);
The simply transparent sectors of the base image are "rendered" as they should (transparent).
The problem lies on the colored transparent sectors. They are rendered as colored, opaque though.
Eg. transparent red is rendered as just red.
You can see png that I use for my cursor, here:
http://img224.imageshack.us/img224/1438/curzl2.png
Hope I was clear and not tiresome.
Thanks again for the reply.