• 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
    }
  • 相关阅读:
    docker容器之启动容器
    docker镜像之registry
    docker镜像之镜像命名
    习题3
    习题二(1)
    课堂作业4
    课堂作业(电费)
    课堂作业2
    实验4
    实验3
  • 原文地址:https://www.cnblogs.com/fighter/p/2421370.html
Copyright © 2020-2023  润新知