我正在android中创建一个图像过滤器应用程序。我正在从位图中检索像素,然后执行一些rgb工作并将它们设置在另一个位图上。这是我的代码,它无法正常工作。请帮忙
bmOut = Bitmap.createBitmap(bm1.getWidth(),
bm1.getHeight(), bm1.getConfig());
final double GS_RED = 0.299;
final double GS_GREEN = 0.587;
final double GS_BLUE = 0.114;
int A, R, G, B;
int pixel;
int[] pixels = new int[bm1.getHeight()* bm1.getWidth()];
bm1.getPixels(pixels, 0, bm1.getWidth(), 0, 0,bm1.getWidth(), bm1.getHeight());
for (int pix = 0 ; pix< pixels.length;pix++) {
A = Color.alpha(pix);
R = Color.red(pix);
G = Color.green(pix);
B = Color.blue(pix);
R = G = B = (int) (GS_RED * R + GS_GREEN * G + GS_BLUE * B);
pixels[pix] = Color.argb(A, R, G, B);
}
bmOut.setPixels(pixels, 0, bm1.getWidth(), 0, 0,
bm1.getWidth(), bm1.getHeight());