Created
December 13, 2013 17:03
-
-
Save SavvasStephanides/7947508 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Color; | |
import java.awt.Graphics; | |
import java.awt.image.BufferedImage; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
public class Pixelation | |
{ | |
public BufferedImage pixelateImage(File inputFile, int boxSize) throws IOException | |
{ | |
BufferedImage bufferedImage = ImageIO.read(inputFile); | |
for(int w = 0 ; w < bufferedImage.getWidth() ; w+=boxSize) | |
{ | |
for(int h = 0 ; h < bufferedImage.getHeight() ; h+=boxSize) | |
{ | |
Color color = new Color(bufferedImage.getRGB(w, h)); | |
Graphics imageGraphics = bufferedImage.getGraphics(); | |
imageGraphics.setColor(color); | |
imageGraphics.fillRect(w, h, boxSize, boxSize); | |
} | |
} | |
return bufferedImage; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment