zoukankan      html  css  js  c++  java
  • 软工划水日报-安卓端侧部署(4) 4/26

    今天来编写保存图片函数

       //图片储存
        public static String saveBitmap(String name, Bitmap bm, Context mContext) {
            String TargetPath = mContext.getFilesDir() + "/images/";
            Log.d("Save Bitmap", "Save Path="+TargetPath+name);
            if (!fileIsExist(TargetPath)) {
                Log.d("Save Bitmap", "TargetPath isn't exist");
            } else {
                //如果指定文件夹创建成功,那么我们则需要进行图片存储操作
                File saveFile = new File(TargetPath, name);
    
                try {
                    FileOutputStream saveImgOut = new FileOutputStream(saveFile);
                    // compress - 压缩的意思
                    bm.compress(Bitmap.CompressFormat.JPEG, 80, saveImgOut);
                    //存储完成后需要清除相关的进程
                    saveImgOut.flush();
                    saveImgOut.close();
                    Log.d("Save Bitmap", "The picture is save to your phone!");
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
            return TargetPath+name;
        }

    这个函数可以保存相应的图像到指定目录以便预测及访问历史

  • 相关阅读:
    GPO
    GPO
    GPO
    Active Directory
    Active Directory
    Ethical Hacking
    Tree and Queries CodeForces
    数颜色 HYSBZ
    Powerful array CodeForces
    Group HDU
  • 原文地址:https://www.cnblogs.com/Sakuraba/p/14910235.html
Copyright © 2011-2022 走看看