android - Making specific color in bitmap transparent -


i have android application display image on image, such second image's white colour transparent. this, have used 2 imageviews, original image overlaid bitmap1 , image made transparent bitmap2. when run this, exceptions @ setpixel method.

here's code:

bitmap bitmap2 = null; int width = imviewoverlay.getwidth(); int height = imviewoverlay.getheight(); for(int x = 0; x < width; x++) {     for(int y = 0; y < height; y++)     {         if(bitmap1.getpixel(x, y) == color.white)         {             bitmap2.setpixel(x, y, color.transparent);         }         else         {             bitmap2.setpixel(x, y, bitmap1.getpixel(x, y));         }     } } 

imviewoverlay imageview of overlay image. idea might going wrong in above code?

the obvious error you're not creating bitmap2 - unless you've not posted code of course.

you declare , set null, don't else until try call bitmap2.setpixel.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -