打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
安卓程序获取缩略图
  •  public static Bitmap decodeBitmap(String path, int displayWidth, int displayHeight){  
  •         BitmapFactory.Options op = new BitmapFactory.Options();  
  •         op.inJustDecodeBounds = true;  
  •         Bitmap bmp = BitmapFactory.decodeFile(path, op); //获取尺寸信息  
  •         //获取比例大小  
  •         int wRatio = (int)Math.ceil(op.outWidth/(float)displayWidth);  
  •         int hRatio = (int)Math.ceil(op.outHeight/(float)displayHeight);  
  •         //如果超出指定大小,则缩小相应的比例  
  •         if(wRatio > 1 && hRatio > 1){  
  •             if(wRatio > hRatio){  
  •                 op.inSampleSize = wRatio;  
  •             }else{  
  •                 op.inSampleSize = hRatio;  
  •             }  
  •         }  
  •         op.inJustDecodeBounds = false;  
  •         bmp = BitmapFactory.decodeFile(path, op);  
  •         return Bitmap.createScaledBitmap(bmp, displayWidth, displayHeight, true);  
  •     }  
  • 本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
    打开APP,阅读全文并永久保存 查看更多类似文章
    猜你喜欢
    类似文章
    【热】打开小程序,算一算2024你的财运
    Android多媒体学习一:Android中Image的简单实例。
    Android获取图片大小以及获取指定大小的缩略图
    java.lang.OutOfMemoryError:?bitmap?size?excee...
    Android项目实战
    最新javascript自动按比例显示图片,按比例压缩图片显示
    用Authorware制作精美功能菜单
    更多类似文章 >>
    生活服务
    热点新闻
    分享 收藏 导长图 关注 下载文章
    绑定账号成功
    后续可登录账号畅享VIP特权!
    如果VIP功能使用有故障,
    可点击这里联系客服!

    联系客服