Finally got per-pixel alpha mask working on w32. The included image isn't the greatest for showing an antialiased edge (it does have one), but if you have something with a drop shadow lying about, just drop it on the demo window and that'll be used instead.
Update This demo works on Windows, OSX and Linux (Linux requires JRE1.5+).
Update Here's another image to drop on the demo window, which better demonstrates the alpha blending, in case you don't have any handy
I've got some working X11 code, too, but I need to figure out a decent API to make it happen. OSX lets you just set the window background pixel transparent and then everything you paint in the window is automatically composited with whatever alpha mask you paint with. That could probably work with Swing as well, but you have to magically drop anything with a default background. OSX does this by checking for a magic UIResource color; anything painted with that color is fully transparent.
Update Source is available on BRANCH_V2 from JNA.
I realize I may be an utter dolt, but I find it really hard to follow Microsoft APIs. I've worked with Qt, X11/Xt, and Mac, each of which has its peculiarities of architecture, but those have a consistency (might I say design) that spans more than two or three functions.
Wednesday, April 18, 2007
Subscribe to:
Post Comments (Atom)
10 comments:
Awesome! This is exactly what I was trying to do, cool stuff!
Dude, *that* is inspiring. Keep it up.
any source code to share?
Source is available from http://jna.dev.java.net. This bit isn't in the repository just yet.
Very slick! Is this in the repository yet, or, can it be soon? Im only interested in Windows support (as I've got Mac working for what I need).
Yes, it's in the repo now, including a WindowUtils.setWindowTransparent() method that will effectively apply your Graphics transparency to the entire window (if you paint something opaque, you get opaque pixels, if you paint nothing, you get a transparent pixel).
where can I get the code? I am interested in Linux version. Got the other two
All code is available from the JNA project page at http://jna.dev.java.net.
All code here is available from the SVN repository on the trunk.
The website to get code http://jna.dev.java.net is not working. I traverse in github repo of yours, but could not find relevant files. Can you please tell where exactly one has to go to see the code?
The library code is contained within platform.jar; there is now a "contrib" subdirectory that contains the alpha mask demo.
Post a Comment