Skip to main content

Rectangle Problem

1 reply [Last post]
gimme5_2
Offline
Joined: 2010-01-26
Points: 0

Hello Experts,
at the moment I need to get some parts of one image and put it into another. I do this by:
1. Generating a "PlanarImage" from a "RenderImage"
2. Writing out a "BufferedImage" with height and length of the source image
3. Setting background of output file to white
4. Creating a Rectangle Object to choose the image part of the source image
5. getting the data as Raster Object
6. Writing it out to the output file
Now, when I open the output file, it shows the area that I cut out with a black background and the rest of the background is white. How can I invert the background area of the rect?

Reply viewing options

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

It would be simpler (and possibly more efficient) to do this with JAI
operators. Look at the "overlay" operator, or possibly "mosaic" or
"composite". You may need "translate" and/or "crop". They are designed
to do exactly what you want... put parts of one image into another. If
the background image is all the same color, you can use "constant" to
create it. But it works just as well if the background is an image
loaded from somewhere, too.

Hope that helps...

-Bob

jai-interest@javadesktop.org wrote:
> Hello Experts,
> at the moment I need to get some parts of one image and put it into another. I do this by:
> 1. Generating a "PlanarImage" from a "RenderImage"
> 2. Writing out a "BufferedImage" with height and length of the source image
> 3. Setting background of output file to white
> 4. Creating a Rectangle Object to choose the image part of the source image
> 5. getting the data as Raster Object
> 6. Writing it out to the output file
> Now, when I open the output file, it shows the area that I cut out with a black background and the rest of the background is white. How can I invert the background area of the rect?
> [Message sent by forum member 'gimme5_2' (maurice.malherbe@iqdoq.de)]
>
> http://forums.java.net/jive/thread.jspa?messageID=382981
>
> ---------------------------------------------------------------------
> 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