DavidNorgren

Untitled

Apr 24th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. private Bitmap pixelateImage(Bitmap img, int amount) {
  2. int imgWidth = img.getWidth();
  3. int imgHeight = img.getHeight();
  4.  
  5. Bitmap editBitmap = Bitmap.createBitmap(imgWidth, imgHeight, Bitmap.Config.ARGB_8888);
  6.  
  7. for (int x = 0; x < imgWidth; x++) {
  8. for (int y = 0; y < imgHeight; y++) {
  9. int snapx, snapy;
  10. snapx = (x / amount) * amount;
  11. snapy = (y / amount) * amount;
  12. editBitmap.setPixel(x, y, img.getPixel(snapx, snapy));
  13. }
  14. }
  15.  
  16. return editBitmap;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment