First of all i would say i was pretty confused in doing this task
but later on it became like a cake walk
this is pretty simple just basic mathematics , kind of set language may be
For doing this i need two images one is the mask image and other is the frame image
just like the above images one image is inner and outer heart is transparent and one with outside alone transparent what we gonna do is combine this two images
using a image view and bitmap thats it find the code below
public void makeMaskImage(ImageView mImageView, Bitmap mContent)
{
//Bitmap original = BitmapFactory.decodeResource(getResources(), mContent);
Bitmap original = mContent;
Bitmap mask = BitmapFactory.decodeResource(getResources(),R.drawable.heart_1_mask);
Bitmap result = Bitmap.createBitmap(mask.getWidth(), mask.getHeight(), Config.ARGB_8888);
Canvas mCanvas = new Canvas(result);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mCanvas.drawBitmap(original, 0, 0, null);
mCanvas.drawBitmap(mask, 0, 0, paint);
paint.setXfermode(null);
mImageView.setImageBitmap(result);
mImageView.setScaleType(ScaleType.FIT_START);
mImageView.setBackgroundResource(R.drawable.heart_1_frame);
}
this does the job for me,Happy coding
No comments:
Post a Comment