*
The moose likes Swing / AWT / SWT and the fly likes How specify to graphics2d which colors should be of what alpha level? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How specify to graphics2d which colors should be of what alpha level?" Watch "How specify to graphics2d which colors should be of what alpha level?" New topic
Author

How specify to graphics2d which colors should be of what alpha level?

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
I have an image where i want to allow someone to pick which colors are of custom alpha level. So for example, they could click on pixel (x=5, y=23) which, let's say is Color(245,123,119). Then they say, that color is alpha 0.4. So everywhere in the image where that pixel appears, the graphics object will paint it with an alpha level of .4.

How would i do this?
Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
anyone know?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You might be able to use RGBImageFilter ( here's an example of using RGBImageFilter to replace one color in an image with another color) not sure if this would work with alpha values, but it might if you specifiy alpha values on the original color.

If not, you should be able to use ColorConvertOp (converting color image to grayscale example http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Supplements/Chapter11/rescaleConvert.html ) this is slightly more involved, but should definitely support alpha values.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How specify to graphics2d which colors should be of what alpha level?