Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int arrayPixels[][] = new int[200][200];
- int width = mImageViewHaosCenter.getMeasuredWidth();
- int height = mImageViewHaosCenter.getMeasuredHeight();
- Bitmap bitmap = ((BitmapDrawable) mImageViewHaosCenter.getDrawable()).getBitmap();
- for (int i = 0; i < width; i++){
- for (int m = 0; m < height; m++){
- int pixel = bitmap.getPixel(i, m);
- int isBlack = 0;
- if (pixel == Color.WHITE)
- isBlack = 0;
- else if (pixel == Color.BLACK)
- isBlack = 1;
- arrayPixels[i][m] = isBlack;
- }
- }
- Bitmap bitmapBottom = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);
- for (int i = 0; i < 200; i++){
- for (int m = 0; m < 200; m++){
- if (arrayPixels[i][m] == 0)
- bitmapBottom.setPixel(i, m, Color.WHITE);
- else if (arrayPixels[i][m] == 1)
- bitmapBottom.setPixel(i, m, Color.BLACK);
- }
- }
- mImageViewHaosBottom.setImageDrawable(new BitmapDrawable(getResources(), bitmapBottom));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement