I have an image which is monochrome, meaning only white and black pixels. I have made several versions of the image in order to cover all dpi folders. I am using a monochrome image since I want to apply the floodfill algorithm. The problem is that in some devices, android uses resized versions of the images and while scaling there are some grey pixels. In order to deal with this I tried correcting the pixels and converting the grey to either white or black, but this takes significant time. Is it possible to force android to generate monochrome images while resizing the imageview or to apply a quick filter to regenerate the monochrome image? While I haven't tried it, should I generate different versions of the images in the nodpi folder and use them without scaling, perhaps with center crop?
Asked
Active
Viewed 106 times
0
-
As an alternative: Could you try to work with the bitmaps and set the result to the imageview? – Christopher Mar 23 '16 at 10:24
-
You mean to work with the drawable image and not the imageview? How can I do that? All I need is a bitmap that I am getting from the imageview! If I can get it directly from the image file, I think I am saved! – George Mar 23 '16 at 15:12
1 Answers
0
You can load the Drawable as Bitmap.
final BitmapFactory.Options options = new BitmapFactory.Options();
// Load the bitmap as mutable object
options.inMutable = true;
final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.my_image, options);
Then you can manipulate it with your algorithm and finally you will set the result to your ImageView
imageView.setImageBitmap(bitmap);
This way you should not get any grey pixels caused by Android Scaling.
For more options:

Christopher
- 9,682
- 7
- 47
- 76
-
After the 4 lines of code and before running my algorithm, I need to scale the image to the size of the screen and then assign it to the imageView. If I don't do that and assign directly the bitmap to the imageView at the last step shouldn't I get the same result? When I apply the algorithm I must have a bitmap as large as the screen so I must resize the image in the drawable folder. – George Mar 24 '16 at 16:22