我想制作一个称为流行艺术滤镜的滤镜
我正在尝试此解决方案
public static Bitmap setPopArtGradientFromBitmap(Context context, Bitmap bmp) {
int[] co = new int[]{Color.parseColor("#FFD900"),Color.parseColor("#FF5300"),Color.parseColor("#FF0D00"),Color.parseColor("#AD009F"),Color.parseColor("#1924B1")};
float[] coP = new float[]{0.2f,0.4f,0.6f,0.8f,1.0f};
Bitmap bitmap = bmp.copy(Bitmap.Config.ARGB_8888, true);
Canvas canvas = new Canvas(bitmap);
/* Create your gradient. */
LinearGradient grad = new LinearGradient(0, 0, 0, canvas.getHeight(), co, coP, Shader.TileMode.CLAMP);
/* Draw your gradient to the top of your bitmap. */
Paint p = new Paint();
p.setStyle(Paint.Style.FILL);
p.setAlpha(110);
p.setShader(grad);
canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), p);
return bitmap;
}
还有我得到的结果。