• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java paint question  RSS feed

 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to chnage white image background to transparent using Java 2D API? I know how to set composite to turn whole image transparent, but I am wondering if I can set selective color of the image as transparent?? Is that possible? How can I do this?

Any pointers, suggestions would be highly appreciated.

TIA,
- Manish
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The BufferedImage class has provisions for 4-byte images, where in addition to the color channels R, G and B there is an alpha channel A that can be used to control transparency on a pixel-by-pixel basis. I've never used its alpha channel capabilities, so I'm not sure if they get displayed that way too, or if it's just for reading/writing files.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look in this folder
sdk1.5/src/com/sun/java/swing/plaf/windows/XPStyle
in your sdk for the convertToTransparent method.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!