Q:

How to adjust Hue / Saturation of a Bitmap?

I need a way to adjust hue/sat of a Bitmap. So far I found this
public static Bitmap colorize(Bitmap src, float hue, float saturationDelta, float valueDelta) {

    Bitmap b = src.copy(Bitmap.Config.ARGB_8888, true);

    for (int x = 0; x < b.getWidth(); x++) {
        for (int y = 0; y < b.getHeight(); y++) {
            int color = b.getPixel(x, y);
            float[] hsv = new float[3];
            Color.colorToHSV(color, hsv);
            hsv[0] = hue;
            hsv[1] += saturationDelta;
            hsv[2] += valueDelta;
            int newColor = Color.HSVToColor(Color.alpha(color), hsv);
            b.setPixel(x, y, newColor);
        }
    }

    return b;
}

But it takes like 10 seconds to work on a 400x500 bitmap. Are there any faster ways?
Thanks! :)

A:

The link I've posted above should help with hue adjustment. In general, the reason the above code is so slow is because you're calling getPixel() and setPixel() for EVERY PIXEL in the image. You should instead use the getPixels() and setPixels() methods to get all of the pixels as an array, loop over that array and do the modification, then set the modified array back to the bitmap all at once. You'll notice an enormous speed improvement.

