Avnish Singh
- Forum posts: 2
May 24, 2013, 11:41:32 AM via Website
May 24, 2013 11:41:32 AM via Website
How to perform an action in android according to which we can drag and adjust the image in image View of android and then apply masking to it.
Below is my code for masking an image
public void mask(Bitmap original){
Bitmap mask = BitmapFactory.decodeResource(getResources(),R.drawable.full_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);
view.setImageBitmap(result);
//view.setScaleType(ScaleType.CENTER);
view.setBackgroundResource(R.drawable.overlay_outlines);
view.invalidate();
}
But this code is only for masking .How can i drag and adjust the image first and then perform masking on it .like mask only the human face in image .
Below is my code for masking an image
public void mask(Bitmap original){
Bitmap mask = BitmapFactory.decodeResource(getResources(),R.drawable.full_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);
view.setImageBitmap(result);
//view.setScaleType(ScaleType.CENTER);
view.setBackgroundResource(R.drawable.overlay_outlines);
view.invalidate();
}
But this code is only for masking .How can i drag and adjust the image first and then perform masking on it .like mask only the human face in image .
— modified on May 24, 2013, 1:47:22 PM
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.