How do you make an BufferedImage transparent.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Taruvai_Subramaniam
Posted On:   Tuesday, May 1, 2001 12:43 PM

I am reading a gif image and performing a number of BufferedImageops on it in java 2D. I then want to send it to the servlet outputStream but with the background color set to transparent. I am using the www.acme.com's Gif Encoder.

It won't help me to read the image as transparent Gif 89a since for some reason the image is completely dark after the processing. I have saved the image as Gif 87 except that I no longer have transparency and then everthing goes well.

Re: How do you make an BufferedImage transparent.

Posted By:   AlessandroA_Garbagnati  
Posted On:   Tuesday, May 1, 2001 04:48 PM

Hi,

It looks like the color model that you are using doesn't have the transparent value set.

I've had a similar problem with the same encoder, but I was generating the image on the fly, so when I was creating the BufferedImage, I've used an IndexColorModel that I've build defining (in the contructor) which one was the transparent color:

public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, int trans);



Now I've finally moved to jpeg. Sun's Jpeg encoder and decoder are way faster than the acme's encoder. The only problem is that JPeg has no transparency, but setting the background to the right color does the trick most of the times.
About | Sitemap | Contact