zoukankan      html  css  js  c++  java
  • Bitmap 压缩 compress 示例

    int count = bitmap.getWidth() * bitmap.getHeight() / 1024;
    Log.d("bitmap:compress", "压缩前:" + count);
    ByteArrayOutputStream output= new ByteArrayOutputStream();
    // 第二个参数表示压缩质量,100表示不压缩,把压缩后的数据存放到output中
    bitmap.compress(Bitmap.CompressFormat.JPEG, 50, output); 
    count = bitmap.getWidth() * bitmap.getHeight() / 1024;
    Log.d("bitmap:compress", "压缩后:" + count);
    Log.d("bitmap:compress", "压缩后:" + output.toByteArray().length / 1024);
    
    bitmap.recycle();//释放bitmap占用的内存

    运行以上代码--输出: 

    压缩前 85 

    压缩后 85 

    压缩后 24  --

     

    如果将第二个参数50改为10 则会

    压缩前 85 

    压缩后 85 

    压缩后 13  --

  • 相关阅读:
    vb 动态添加 timer
    sruts2 国际化 规范
    vb 创建xml
    robots
    android 桌面斗地主
    QT 平台
    云软件 Eucalyptus云
    android intentfilter
    android 布局相关
    Zend Studio PHP
  • 原文地址:https://www.cnblogs.com/FTDtt/p/4682516.html
Copyright © 2011-2022 走看看