zoukankan      html  css  js  c++  java
  • android 按比例获取SD卡缩略图

                     BitmapFactory.Options options = new BitmapFactory.Options();  
    options.inJustDecodeBounds = true;

    //获取这个图片的宽和高
    Bitmap bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+ "/darunfa/temp.jpg",options);//此时返回bm为空
    options.inJustDecodeBounds =false;
    //计算缩放比
    int be = (int)(options.outWidth / (float)600);
    if(be <= 0)
    be = 1;
    options.inSampleSize = be;
    //重新读入图片,注意这次要把options.inJustDecodeBounds设为false哦
    bitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath()+ "/darunfa/temp.jpg",options);
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();
    System.out.println(w+" "+h);
    imageView.setImageBitmap(bitmap);

    File file2= new File(Environment.getExternalStorageDirectory().getAbsolutePath()+ "/darunfa/aaaa.jpg");
    try {
    FileOutputStream out = new FileOutputStream(file2);
    if(bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out)){
    out.flush();
    out.close();
    }
    } catch (Exception e) {
    // TODO: handle exception
    }
  • 相关阅读:
    移动端
    移动端
    Jmeter-接口功能测试
    Jmeter-连接 MySQL数据库
    Jmeter-安装与配置
    postman接口功能测试
    移动端
    移动端
    loadrunner实战篇
    【转载】格式化存储装置成为 Ext2/Ext3/Ext4 档案系统
  • 原文地址:https://www.cnblogs.com/fighter/p/2421370.html
Copyright © 2011-2022 走看看