私は単純な画像操作クラスを使用することになりました:
import android.graphics.Bitmap;
import android.graphics.Color;
/**
* Image with support for filtering.
*/
public class FilteredImage {
private Bitmap image;
private int width;
private int height;
private int[] colorArray;
/**
* Constructor.
*
* @param img the original image
*/
public FilteredImage(Bitmap img) {
this.image = img;
width = img.getWidth();
height = img.getHeight();
colorArray = new int[width * height];
image.getPixels(colorArray, 0, width, 0, 0, width, height);
applyHighlightFilter();
}
/**
* Get the color for a specified pixel.
*
* @param x x
* @param y y
* @return color
*/
public int getPixelColor(int x, int y) {
return colorArray[y * width + x];
}
/**
* Gets the image.
*
* @return Returns the image.
*/
public Bitmap getImage() {
return image;
}
/**
* Applies green highlight filter to the image.
*/
private void applyHighlightFilter() {
int a;
int r;
int g;
int b;
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int c = getPixelColor(x, y);
a = Color.alpha(c);
r = Color.red(c);
g = Color.green(c);
b = Color.blue(c);
r = (int) (r * 0.8);
g = (int) (g * 1.6);
b = (int) (b * 0.8);
if (r > 255) {
r = 255;
}
if (r < 0) {
r = 0;
}
if (g > 255) {
g = 255;
}
if (g < 0) {
g = 0;
}
if (b > 255) {
b = 255;
}
if (b < 0) {
b = 0;
}
int resultColor = Color.argb(a, r, g, b);
image.setPixel(x, y, resultColor);
}
}
}
}