我有一个安卓应用程序,使用以下代码增加图像亮度。但是这种方法非常缓慢,是否有更快的方法来提高安卓ImageView图像亮度?请注意,这是改善ImageView亮度而不是屏幕亮度。
public static Bitmap doBrightness(Bitmap src, int value) {
//Log.e("Brightness", "Changing brightnhjh");
int width = src.getWidth();
int height = src.getHeight();
Bitmap bmout = Bitmap.createBitmap(width, height, src.getConfig());
int A, R, G, B;
int pixel;
for (int i = 0; i < width; i=i++) {
for (int j = 0; j < height; j=j++) {
pixel = src.getPixel(i, j);
A = Color.alpha(pixel);
R = Color.red(pixel);
G = Color.green(pixel);
B = Color.blue(pixel);
R += value;
if (R > 255) {
R = 255;
} else if (R < 0) {
R = 0;
}
G += value;
if (G > 255) {
G = 255;
} else if (G < 0) {
G = 0;
}
B += value;
if (B > 255) {
B = 255;
} else if (B < 0) {
B = 0;
}
bmout.setPixel(i, j, Color.argb(A, R, G, B));
}
}
return bmout;
}
这是ImageView控件
imageview.setImageBitmap(doBrightness(image, 40));