Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. int arrayPixels[][] = new int[200][200];
  2. int width = mImageViewHaosCenter.getMeasuredWidth();
  3. int height = mImageViewHaosCenter.getMeasuredHeight();
  4. Bitmap bitmap = ((BitmapDrawable) mImageViewHaosCenter.getDrawable()).getBitmap();
  5. for (int i = 0; i < width; i++){
  6. for (int m = 0; m < height; m++){
  7. int pixel = bitmap.getPixel(i, m);
  8. int isBlack = 0;
  9. if (pixel == Color.WHITE)
  10. isBlack = 0;
  11. else if (pixel == Color.BLACK)
  12. isBlack = 1;
  13. arrayPixels[i][m] = isBlack;
  14. }
  15. }
  16. Bitmap bitmapBottom = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
  17. for (int i = 0; i < 200; i++){
  18. for (int m = 0; m < 200; m++){
  19. if (arrayPixels[i][m] == 0)
  20. bitmapBottom.setPixel(i, m, Color.WHITE);
  21. else if (arrayPixels[i][m] == 1)
  22. bitmapBottom.setPixel(i, m, Color.BLACK);
  23. }
  24. }
  25. mImageViewHaosBottom.setImageDrawable(new BitmapDrawable(getResources(), bitmapBottom));
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement