paint - Changing specific colors in a bitmap , Android -
suppose have 3 bitmaps 2 colors on them.
- red , white
- blue , white
- 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
Post a Comment