Skip to main content

[JAVA2D] Clipping in Raster operations...

1 reply [Last post]
Anonymous

Guys and gals,

I am a lost server programmer, who rarely ventures into the GUI domain, but I
am now working on a little server component that can apply a stack of raster
operations on an image. This is for the Apache Cocoon project, and not per se
commercial, although we ourselves use it commercially.

So, I read the image inputstream, and creates a WriteableRaster, which is
passed through a stack of operations before being serialized back to an
outputstream (typically a http request).

Now, all this is fine and dandy, except I can not work out how to avoid
clipping in the negative region. It seems that any AffineTransform clips any
pixels ending up on negative coordinates.

Does anyone has any links to more info what to do about this?

I.e. what goes into the method below?

public class RotationOperation
implements ImageOperation
{
public WritableRaster transform( WritableRaster input )
{
// ??
}
}

Thanks for any help on this.

Cheers
Niclas
--
+------//-------------------+
/ http://www.bali.ac /
/ http://niclas.hedhman.org /
+------//-------------------+

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

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

> Now, all this is fine and dandy, except I can not work out how to avoid
> clipping in the negative region. It seems that any AffineTransform clips
> any pixels ending up on negative coordinates.

BufferedImage objects all have implicit origins of 0,0 and only include
pixels with positive coordinates. Thus, the AffineTransformOp, which
places its results into a BufferedImage object, has no place to put the
pixels which fall on negative coordinates.

If you want those pixels then you need to make sure that the AffineTransform
that you supply to the AffineTransformOp has an appropriate translation
applied to move all of the coordinates back into the positive domain.

You should be able to get the bounds of the operation from the Op and
then apply the origin of those bounds to the AffineTransform using the
translate method. You will then need to create a new AffineTransformOp
with the new translated AffineTransform...

...jim

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".