Transparency in Java Imaging  
Author Message
Bernhard Messerer





PostPosted: 2003-8-6 17:56:00 Top

java-programmer, Transparency in Java Imaging Hi all!

When I have multiple images in Java (I'm using JAI, but I thing this has
to do with ColorModel, which is present in AWT) which I want to stack
above each other, is there any possibility to define white as
"transparent", i.e. whenever an image contains white pixels they should
not be drawn... any ideas?
If this is impossible, how else do I use transparency when drawing
images? (i.e. how can I stack them, without each overwriting the image
below it)?

thanks in advance and kind regards,

Messi

 
Liu, Chunyen





PostPosted: 2003-8-6 21:41:00 Top

java-programmer >> Transparency in Java Imaging
Check the article with source code at:

"Maintaining Transparency for Image Transformations"
http://www.developer.com/java/other/article.php/895051

Thanks,

> -----Original Message-----
> From: Bernhard Messerer [SMTP:email***@***.com]
> Posted At: Wednesday, August 06, 2003 4:56 AM
> Posted To: comp.lang.java.programmer
> Conversation: Transparency in Java Imaging
> Subject: Transparency in Java Imaging
>
> Hi all!
>
> When I have multiple images in Java (I'm using JAI, but I thing this
> has
> to do with ColorModel, which is present in AWT) which I want to stack
> above each other, is there any possibility to define white as
> "transparent", i.e. whenever an image contains white pixels they
> should
> not be drawn... any ideas?
> If this is impossible, how else do I use transparency when drawing
> images? (i.e. how can I stack them, without each overwriting the image
>
> below it)?
>
> thanks in advance and kind regards,
>
> Messi

 
google





PostPosted: 2003-8-6 21:49:00 Top

java-programmer >> Transparency in Java Imaging Hi Messi,

I presume you're loading in these images from external files. One
solution is to simply set those pixels as transparent in an image
editing program. For example, if you save GIF files in Photoshop with
a certain color marked as transparant, Java will do the right thing.

-Josh
 
 
google





PostPosted: 2003-8-6 21:51:00 Top

java-programmer >> Transparency in Java Imaging Or here's a pointer to a page that describes how to do exactly what
you want. It was the number 2 hit from a google search for: java set
color transparent image.

I hope this helps.

http://www.rgagnon.com/javadetails/java-0265.html
 
 
Neomorph





PostPosted: 2003-8-8 16:37:00 Top

java-programmer >> Transparency in Java Imaging On Wed, 06 Aug 2003 17:45:29 +0200, Bernhard Messerer
<email***@***.com> two-finger typed:

>JCM,
>
>Thanks for your replies. Yes, currently I'm using images with integrated
>alpha channel, but this proves difficult, as the images get larger and
>because of the sheer mass of images, it is diffcult to add an alpha
>channel everywhere; also, other applications cannot use the images
>anymore then...
>The second approach has the flaw that it exclusively works with AWT
>images where one can use getRGB() and setRGB(). This doesn't seem to be
>an option, as I'm using JAI RenderedOps. Earlier I used BufferedImages
>(which provide getRGB() and setRGB()) methods but that was _very_ slow
>decoding images into BIs (I have no idea why, it shouold simply contain
>a raster of pixels, right?).

You can also create your own image from a buffer (array) of int-s using a
MemoryImageSource.
Each int is one pixel: (8bit alpha)(8-bit red)(8-bit green)(8-bit blue)
(most significant bits on the left, of course).

If you change the contents of the int array, you can directly change colors
and alpha channel in the fastest way.

I used this for a mandelbrot generator :)

>
>kind regards,
>Messi
>

Cheers.
>JCM wrote:
>
>> Or here's a pointer to a page that describes how to do exactly what
>> you want. It was the number 2 hit from a google search for: java set
>> color transparent image.
>>
>> I hope this helps.
>>
>> http://www.rgagnon.com/javadetails/java-0265.html

 
 
Bernhard Messerer





PostPosted: 2003-8-11 15:42:00 Top

java-programmer >> Transparency in Java Imaging Thanks for your response,

This allows me to do it for AWT imaging; However, this is too slow (as I
have e.g. three layers 8x5 images = 40x3=120 images, 80 to overlay). I
first tried with AWT imaging but converted to JAI because the latter was
MUCH faster... and how to do it there?

regards,

Messi

Liu, Chunyen wrote:
> Check the article with source code at:
>
> "Maintaining Transparency for Image Transformations"
> http://www.developer.com/java/other/article.php/895051
>
> Thanks,
>
>
>>-----Original Message-----
>>From: Bernhard Messerer [SMTP:email***@***.com]
>>Posted At: Wednesday, August 06, 2003 4:56 AM
>>Posted To: comp.lang.java.programmer
>>Conversation: Transparency in Java Imaging
>>Subject: Transparency in Java Imaging
>>
>>Hi all!
>>
>>When I have multiple images in Java (I'm using JAI, but I thing this
>>has
>>to do with ColorModel, which is present in AWT) which I want to stack
>>above each other, is there any possibility to define white as
>>"transparent", i.e. whenever an image contains white pixels they
>>should
>>not be drawn... any ideas?
>>If this is impossible, how else do I use transparency when drawing
>>images? (i.e. how can I stack them, without each overwriting the image
>>
>>below it)?
>>
>>thanks in advance and kind regards,
>>
>>Messi
>
>