zoukankan      html  css  js  c++  java
  • android 保存Bitmap 到本地 哦

    public String saveImage(Bitmap bmp) {

    File appDir = new File(Environment.getExternalStorageDirectory(), "Boohee");
    if (!appDir.exists()) {
    appDir.mkdir();
    }
    String fileName = System.currentTimeMillis() + ".jpg";
    File file = new File(appDir, fileName);

    try {
    FileOutputStream fos = new FileOutputStream(file);
    bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos);
    fos.flush();
    fos.close();
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }
    return file.getAbsolutePath();
    }


    用 Zxing 生成二维码 并保存到本地的时候 会看到保存本地的是一张黑色的图 但是用imageview 看到的正常的

    因为 imageview 在显示图片时 默认不没有颜色的地方设置成白色了 但是 保存到本地时 它会将没有颜色的地方默认显示成黑色 所有你看到的是全黑色的

    解决方案是 在Zxing 生成图片的时候 加上该代码

    
    
  • 相关阅读:
    Section 3.1 Shaping Regions
    3D@OpenSource
    查找资料
    Section 3.1 Shaping Regions Again
    USACO Contact IOI’98 TLE
    事项ON丰宁坝上草原
    四叉树@POJ1610 Quad Trees
    在TabCtrl上放View@MFC
    CUGB的一场周赛
    贴图程序进展
  • 原文地址:https://www.cnblogs.com/jeno-song/p/6230465.html
Copyright © 2011-2022 走看看