Freehand Image Crop draw inside bitmap region

醉酒当歌 提交于 2019-12-03 03:03:12

late answer but use full for other u can override onmeasure method and set your image bitmap width and height in that method and resize your canvas so now you can draw only in your canvas.so your image come center.it for drawpath only on your bitmap.

 @Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    height = bitmap.getHeight();
    width = bitmap.getWidth();

    setMeasuredDimension(width,height);
}

and then change in your oncrop method so you can slove it esaly.

Bitmap resultingImage = Bitmap.createBitmap(yourbitmap.getwidth(),yourbitmap.getheight(), yourbitmap.getConfig());

There is one way to achieve your goal..

Follow below steps:

1) Make one image like as inside part of crop image should be transparent and outside part should be background of canvas check below Image.

2) Draw that image on top of your canvas.

3) Draw anything on your canvas and drawagain that image on top of the canvas.

Image:

You can ignore all Touch Events that are outside your image view. Remember the last event location that is inside your image view and connect it with the next event location that is inside the view. This should work when both events are part of a single movement (without lifting your finger), but it might be more complicated when the drawing is done outside your view and then a new drawing starts inside. Try to cover this case too.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!