paint - Changing specific colors in a bitmap , Android -


suppose have 3 bitmaps 2 colors on them.

  1. red , white
  2. blue , white
  3. green , white

now want change red , blue , green colours in 3 images respectively colour. ex :black.

what approach take ?

i read replacing colours , successful in replacing particular colours. ex: able replace red , blue , green individually specifying colour want change.

but how make generic ? can suggest approach towards ?

you can use approach here: replace black color in bitmap red , add more tests inside if statement.

int [] allpixels = new int [ mybitmap.getheight()*mybitmap.getwidth()];  mybitmap.getpixels(pixels, 0, mybitmap.getwidth(), 0, 0,mybitmap.getwidth(),mybitmap.getheight());  for(int =0; i<mybitmap.getheight()*mybitmap.getwidth();i++){      if( allpixels[i] == color.red || allpixels[i] == color.blue || allpixels[i] == color.green)          allpixels[i] = color.black; }  mybitmap.setpixels(allpixels, 0, mybitmap.getwidth(), 0, 0, mybitmap.getwidth(), mybitmap.getheight()); 

then can make function takes array of colors argument.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -