Android: Cropping an image to specific size

后端 未结 2 474
鱼传尺愫
鱼传尺愫 2021-02-02 04:31

My intention is to have the user pick an image from the gallery, then have a cropping activity come up. However, I need the rectangle that defines the cropping mask to be locked

2条回答
  •  醉梦人生
    2021-02-02 05:03

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null)
                .setType("image/*")
                .putExtra("crop", "true")
                .putExtra("aspectX", width)
                .putExtra("aspectY", height)
                .putExtra("outputX", width)
                .putExtra("outputY", height)
                .putExtra("scale", true)
                .putExtra("scaleUpIfNeeded", true)
                .putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f))
                .putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
    

提交回复
热议问题