I'm trying to draw a square image into a trapezoid using the Java Advanced Imaging API; However after creating a PerspectiveTransform I am unsure how I would go about applying it to a graphics object or image.
Asked
Active
Viewed 1,253 times
3
-
Cross posted: http://www.java-forums.org/java-2d/47818-render-image-into-given-quadrilateral.html#post230234 – camickr Aug 20 '11 at 20:03
1 Answers
0
When you apply a JAI operation, get RenderedOp
, whichever operation (PerspectiveTransform, Scale...) as result. This represents the operation in a chain if you apply several operations to the same image, so the next operation is applied over the RenderedOp
and so on. Finally, you need to draw it, so:
1) Convert it to RenderedImage
in order to apply all calculations to the final image. Use something like:
new BufferedImage(renderedOp.getColorModel(), renderedOp.copyData(), false, null);
2) Draw the image onto a Graphics
using something like:
Graphics2D graphics2D = (Graphics2D)graphics; // Convert the graphics received to Graphics2D to get more operations.
graphics2D.drawRenderedImage(renderedImage, new AffineTransform());

Matthias Braun
- 32,039
- 22
- 142
- 171

David Oliván
- 2,717
- 1
- 19
- 26