www.androidchunk.com

Hi Developer, Please visit www.androidchunk.com for Latest Updates. Thank you!

Image Erasing with Android Canvas

Category: Android Codez | Last Updates: 25/05/2017



In this section We are going to erasing Image/Photo in the Android. 

First of all We change our image into bitmap after that we have to change that bitmap into a mutable bitmap.

Converting drawable resource file into bitmap
Bitmap rawBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.test_img);

Converting bitmap into mutable bitmap
sourceBitmap = Bitmap.createBitmap(rawBitmap.getWidth(), rawBitmap.getHeight(), Bitmap.Config.ARGB_8888);

We are using PorterDuff.Mode.DST_IN mode for our paint object , Please see below image which describe that what is the PorterDuff.Mode.DST_IN

destPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));


If you want to know more about PorterDuff.Mode click here.

src/MyCustomView.java 

src/MainActivity.java

To Download Source Code click here.

Video Tutorial with Output:


No comments :

Post a Comment