First of all, Android can only compress integers, not decimal compression. It is impossible to compress the image to a width of 720 Secondly, the image is usually reduced to a photo smaller than 720 before displaying it. The area less than 720 can be left empty. Draw the default background color, you can crop it, etc., depending on the specific situation
Bitmap bitmap = getCompressForQualitySize(os, (int) sampleSize); ByteArrayOutputStream osSecond = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, options, osSecond); Use equal scaling, get it first Just set the width and height of the image and then scale it down to 720, but there may be some deviations
You can use it first
inSampleSize
获得一张近似大小的图片,再用Matrix
进行缩放到指定大小嘛╮(╯_╰)╭
First of all, Android can only compress integers, not decimal compression. It is impossible to compress the image to a width of 720
Secondly, the image is usually reduced to a photo smaller than 720 before displaying it. The area less than 720 can be left empty. Draw the default background color, you can crop it, etc., depending on the specific situation
Bitmap bitmap = getCompressForQualitySize(os, (int) sampleSize);
ByteArrayOutputStream osSecond = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, options, osSecond);
Use equal scaling, get it first Just set the width and height of the image and then scale it down to 720, but there may be some deviations