Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perspective Transformations

Status
Not open for further replies.

doubleoseven

Programmer
Dec 6, 2005
1
US
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);
}
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top