Convert white color to transparent on bitmap in android -


i want convert white background transparent background in android bitmap.

my situation:

original image : cannot post image

public bitmap replacecolor(bitmap src){     if(src == null)         return null;     int width = src.getwidth();     int height = src.getheight();     int[] pixels = new int[width * height];     src.getpixels(pixels, 0, width, 0, 0, width, height);     for(int x = 0;x < pixels.length;++x){         pixels[x] = ~(pixels[x] << 8 & 0xff000000) & color.black;     }     bitmap result = bitmap.createbitmap(pixels, width, height, bitmap.config.argb_8888);     return result;     } 

processing after detect pixel pixel, 1 one. it's bitmap image doesn't remain original color.

so, append code filter.

if (pixels[x] == color.white)      public bitmap replacecolor(bitmap src){     if(src == null)         return null;     int width = src.getwidth();     int height = src.getheight();     int[] pixels = new int[width * height];     src.getpixels(pixels, 0, width, 0, 0, width, height);     for(int x = 0;x < pixels.length;++x){         if(pixels[x] == color.white){           pixels[x] = ~(pixels[x] << 8 & 0xff000000) & color.black;         }        }     bitmap result = bitmap.createbitmap(pixels, width, height, bitmap.config.argb_8888);     return result;     } 

processing after,

but, picture can not remove color white. so, not pretty.

i want remove white background in android bitmap

my code following in under stackoverflow article.

android bitmap mask color, remove color


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -