Android how to scale an image with BitmapFactory Options

前端 未结 3 971
眼角桃花
眼角桃花 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:02

    You can try something like this:

    int imageWidth, imageHeight;
    
    Bitmap result = Bitmap.createScaledBitmap(bitmapPicture,
                            imageWidth, imageHeight, false);
    

    Here you can add your own width and height. bitmapPicture is the object of Bitmap. Let me know if this is of any help to you.

提交回复
热议问题