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

Snippets has posted 5883 posts at DZone. View Full User Profile

Java - ZoomOUT Image

10.29.2006
| 7923 views |
  • submit to reddit
        
public BufferedImage zoomOut(BufferedImage bi, int scale)
	{
		int width = bi.getWidth() / scale;
		int height = bi.getHeight() / scale;
		
		BufferedImage biScale = new BufferedImage(width, height, bi.getType());
		
		for(int i=0; i<width; i++)
			for(int j=0; j<height; j++)
				biScale.setRGB(i, j, bi.getRGB(i*scale, j*scale));
		
		return biScale;
	}