我正在尝试存储具有Alpha值的位图以及RGB所有颜色和阴影应用,除了具有值>的Alpha效果。 ColorMatrix中的1.0。
以下是我的代码
Bitmap bm = BitmapFactory.decodeFile(imagePath).copy(Config.ARGB_8888, true);
final Bitmap b = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(),
Bitmap.Config.ARGB_8888);
b.eraseColor(Color.argb(0, 0, 0, 0));
final Canvas c = new Canvas(b);
float redValue = ((float) red) / 255;
float greenValue = ((float) green) / 255;
float blueValue = ((float) blue) / 255;
float alphaValue = ((float) alpha) / 255;
ColorMatrix cm = new ColorMatrix();
cm.set(new float[] { redValue, 0, 0, 0,0,
0, greenValue, 0, 0, 0,
0, 0, blueValue, 0, 0,
0, 0, 0, alphaValue, 0 });
Log.e("cm","cm::"+cm.toString());
Paint p = new Paint();
p.setColorFilter(new ColorMatrixColorFilter(cm));
c.drawBitmap(bm, 0, 0, p);
return b;
您的建议/帮助将不胜感激