I have images that I display in my application. They are downloaded from the Internet. These images are images of objects on an almost white background. I want this background to be white (#FFFFFF). I believe that if I look at the pixel 0,0 (which should always be off-white), I can get the color value and replace each pixel in the image with this value with white.
This question has been asked before, and the answer seems to be as follows:
int intOldColor = bmpOldBitmap.getPixel(0,0); Bitmap bmpNewBitmap = Bitmap.createBitmap(bmpOldBitmap.getWidth(), bmpOldBitmap.getHeight(), Bitmap.Config.RGB_565); Canvas c = new Canvas(bmpNewBitmap); Paint paint = new Paint(); ColorFilter filter = new LightingColorFilter(intOldColor, Color.WHITE); paint.setColorFilter(filter); c.drawBitmap(bmpOriginal, 0, 0, paint);
However, this does not work.
After running this code, the whole image seems to be the color that I wanted to delete. As now, the entire image is now solid.
I also hoped that you would not have to iterate over every pixel in the whole image.
Any ideas?
android bitmap
Andrew
source share