Skip to main content

Making PerspectiveWarp background transparent

2 replies [Last post]
gnarled
Offline
Joined: 2006-02-14

I have a situation where I am loading a jpeg image, performing a perspective warp on it, and then saving it back out to a PNG. By default the perspective warp fills in the background with black. I found that I can change the color of that to any RGB color. But what I want to do is change the alpha to transparent. Does anyone know how to do this?

Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Arthur Pope

Before warping, add an alpha channel to the decoded JPEG, setting that channel
to 255. Create the alpha channel as a single band image using the Constant
operator. Use BandMerge to add the alpha channel to the decoded JPEG. Use an
ImageLayout rendering hint to assign the merged image an appropriate color model
(that of the decoded JPEG but with an alpha channel and bitmask transparency).

jai-interest@javadesktop.org wrote:
> I have a situation where I am loading a jpeg image, performing a perspective warp on it, and then saving it back out to a PNG. By default the perspective warp fills in the background with black. I found that I can change the color of that to any RGB color. But what I want to do is change the alpha to transparent. Does anyone know how to do this?
>
> Thanks.
> ---
> [Message sent by forum member 'gnarled' (Nathaniel Roman)]
>
> http://www.javadesktop.org/forums/thread.jspa?messageID=120950&#120950
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

gnarled
Offline
Joined: 2006-02-14

Sorry but I'm new to JAI, and have no idea what some of those steps meant. Can you explain it a little more or give me a code sample? Thanks.