Modify onDraw() method of MyView.java in the post "Example of using ColorMatrixColorFilter".
@Override
protected void onDraw(Canvas canvas) {
int srcColor= 0xFF00FF00;
PorterDuff.Mode mode = PorterDuff.Mode.ADD;
PorterDuffColorFilter porterDuffColorFilter
= new PorterDuffColorFilter(srcColor, mode);
Paint MyPaint_Normal = new Paint();
Paint MyPaint_PorterDuff = new Paint();
MyPaint_PorterDuff.setColorFilter(porterDuffColorFilter);
Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
canvas.drawBitmap(myBitmap, 400, 100, MyPaint_Normal);
canvas.drawBitmap(myBitmap, 500, 100, MyPaint_PorterDuff);
};
Download the files.
Related:
- Interactive demonstration of PorterDuffColorFilter.
No comments:
Post a Comment