search

Home  >  Q&A  >  body text

Android 缩放Bitmap到指定比例大小

伊谢尔伦伊谢尔伦2772 days ago632

reply all(3)I'll reply

  • 黄舟

    黄舟2017-04-17 16:47:28

    You can use it firstinSampleSize获得一张近似大小的图片,再用Matrix进行缩放到指定大小嘛╮(╯_╰)╭

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 16:47:28

    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

    reply
    0
  • 黄舟

    黄舟2017-04-17 16:47:28

    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

    reply
    0
  • Cancelreply