How to capture a custom image size with the camera in android?

前端 未结 2 1240
悲哀的现实
悲哀的现实 2021-02-05 12:18

How to capture an square image in android? I want to capture an square image (such as 300x300 pixel) by calling Camera through intent in android, how can I do this?

2条回答
  •  独厮守ぢ
    2021-02-05 12:55

    Why nobody mentioned something like this?

    Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, xStart, yStart, 300, 300);
    

    where sourceBitmap is original capture from camera and xStart and yStart location from where cropping will start. The result should have xStart, yStart in top left corner.

提交回复
热议问题