I am trying to create a function that gets the color of a bitmap and fate and returns a color bitmap (without using paint). I found several ways to do this, but nothing works as I want it.
The closest solution I could find is:
public static Bitmap changeImageColor(Bitmap srcBmp, int dstColor) { int width = srcBmp.getWidth(); int height = srcBmp.getHeight(); float srcHSV[] = new float[3]; float dstHSV[] = new float[3]; Bitmap dstBitmap = Bitmap.createBitmap(width, height, Config.RGB_565); for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { Color.colorToHSV(srcBmp.getPixel(col, row), srcHSV); Color.colorToHSV(dstColor, dstHSV);
but it doesn't work very well on transparent images, as you can see here (before and after): 
Anyone have other solutions (again without using paint at all)?
source share