I am using the following method to change the hue of a bitmap:
public Bitmap changeHue( Bitmap source, double hue ) {
Bitmap result = Bitmap.createBitmap( screenWidth, screenHeight, source.getConfig() );
float[] hsv = new float[3];
for( int x = 0; x < source.getWidth(); x++ ) {
for( int y = 0; y < source.getHeight(); y++ ) {
int c = source.getPixel( x, y );
Color.colorToHSV( c, hsv );
hsv[0] = (float) ((hsv[0] + 360 * hue) % 360);
c = (Color.HSVToColor( hsv ) & 0x00ffffff) | (c & 0xff000000);
result.setPixel( x, y, c );
}
}
return result;
}
It works perfectly and maintains the luminance of the bitmap. However this method is very slow when changing the hue of a bitmap size 800*480 or higher. How can I optimize it without losing too much image quality?