Crop particular part of image in android

后端 未结 3 443
孤城傲影
孤城傲影 2020-12-05 12:36

I want to crop Red part from following image, Is there any simple method available in android that can crop following image.

3条回答
  •  一生所求
    2020-12-05 12:49

    1- Change your imageview for bitmap

    final Bitmap bitmap=BitmapFactory.decodeResource(getResources(), R.drawable.img);
    

    2-use your bitmap to crop what you want

    Bitmap croppedBmp = Bitmap.createBitmap(bitmap, x, y , width , height);
    

    3-Take care x,y from Top and left

    4- to preview your bitmap again in your imageview

    imageView.setImageBitmap(croppedBmp);
    

提交回复
热议问题