final Bitmap bmp = /* there your bitmap */;
int w = bmp.getWidth();
int h = bmp.getHeight();
for (int x = 0; x < w; x++) {
for (int y = 0; y < h; y++) {
int color = bmp.getPixel(x, y);
// Shift your alpha component value to the red component's.
color = (color << 24) & 0xFF000000;
bmp.setPixel(x, y, color);
}
}
2 回答
如果您不需要高速,可以通过手动混合像素来使用简单的解决方案 .
如果需要更有效的处理,则必须使用(至少)getPixels方法,或者更优选使用本机处理 .