how to add a photo in a desired position of a frame?

Viewed 542

I am trying to :

  1. Pick a photo from Android gallery (Suppose : person.png)
  2. Cropping the photo as rounded image
  3. Resize the image in 300x300 pixels
  4. Then add the resized image(person.png) on the top of a frame image (frame.png). And the final resulted image will look like this (final_image.png)
  5. Then, save the new image(final_image.png) into gallery with a new name.

person.png

person.png

frame.png

frame.png

enter image description here

final_image.png

Here is my demo code for loading an image in a frame or mask.

    ImageView mImageView= (ImageView)findViewById(R.id.imageview_id);
 Bitmap original = BitmapFactory.decodeResource(getResources(),R.drawable.content_image);
 Bitmap mask = BitmapFactory.decodeResource(getResources(),R.drawable.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.CENTER);
 mImageView.setBackgroundResource(R.drawable.background_frame);
0 Answers
Related