DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Java - Rotate -90°/90°
public BufferedImage rotate90DX(BufferedImage bi)
{
int width = bi.getWidth();
int height = bi.getHeight();
BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
for(int i=0; i<width; i++)
for(int j=0; j<height; j++)
biFlip.setRGB(height-1-j, width-1-i, bi.getRGB(i, j));
return biFlip;
}
public BufferedImage rotate90SX(BufferedImage bi)
{
int width = bi.getWidth();
int height = bi.getHeight();
BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
for(int i=0; i<width; i++)
for(int j=0; j<height; j++)
biFlip.setRGB(j, i, bi.getRGB(i, j));
return biFlip;
}






Comments
Snippets Manager replied on Tue, 2011/09/06 - 5:11am
Snippets Manager replied on Tue, 2011/09/06 - 5:11am
Snippets Manager replied on Tue, 2009/04/28 - 1:20pm
Snippets Manager replied on Wed, 2009/03/11 - 10:28am