Android how to scale an image with BitmapFactory Options

前端 未结 3 950
眼角桃花
眼角桃花 2020-12-18 18:52

I want to decode an image from the SD card with BitmapFactory.decodeFile(path, options).
I also want images that are larger than 2048x2048 pixels to be scaled down to at

3条回答
  •  时光说笑
    2020-12-18 19:14

    Use BitmapFactory.Options.inSampleSize when you first load your image to get the size as close as possible to your target size, then use Bitmap.createScaledBitmap to scale to the exact size you want.

    There's some code for this in this answer.

提交回复
热议问题