doubleoseven
Programmer
I'm trying to learn how to do perspective image transformations and display them in a swing application and have become very confused. Can anyone tell me how to do this? It seems like I'm jumping through all these hoops and still not getting a result. Please help.
This is what I've got so far:
...
ImageIcon icon = createImageIcon("images/image1.png");
Image image2 = icon.getImage();
BufferedImage image1 = new BufferedImage(303,481,BufferedImage.TYPE_INT_ARGB);
Graphics g = image1.getGraphics();
g.drawImage(image2,0,0,null);
PerspectiveTransform pt = new PerspectiveTransform();
Warp warpPerspective = new WarpPerspective(pt);
RenderedOp op = createWarpImage(image1, warpPerspective);
RenderedImage renderedImage = op.createInstance();
PlanarImage pi1 = (PlanarImage)renderedImage;
BufferedImage bi2 = pi1.getAsBufferedImage();
ImageIcon icon2 = new ImageIcon(bi2);
}
public static RenderedOp createWarpImage(RenderedImage img, Warp warp) {
ParameterBlock pb = new ParameterBlock();
pb.addSource(img);
pb.add(warp);
pb.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
return JAI.create("warp", pb);
}
...
This is what I've got so far:
...
ImageIcon icon = createImageIcon("images/image1.png");
Image image2 = icon.getImage();
BufferedImage image1 = new BufferedImage(303,481,BufferedImage.TYPE_INT_ARGB);
Graphics g = image1.getGraphics();
g.drawImage(image2,0,0,null);
PerspectiveTransform pt = new PerspectiveTransform();
Warp warpPerspective = new WarpPerspective(pt);
RenderedOp op = createWarpImage(image1, warpPerspective);
RenderedImage renderedImage = op.createInstance();
PlanarImage pi1 = (PlanarImage)renderedImage;
BufferedImage bi2 = pi1.getAsBufferedImage();
ImageIcon icon2 = new ImageIcon(bi2);
}
public static RenderedOp createWarpImage(RenderedImage img, Warp warp) {
ParameterBlock pb = new ParameterBlock();
pb.addSource(img);
pb.add(warp);
pb.add(Interpolation.getInstance(Interpolation.INTERP_NEAREST));
return JAI.create("warp", pb);
}
...