• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone know?
 
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!