首页 > 学院 > 开发设计 > 正文

我的安卓笔记(注:仅作笔记,有的代码不是原创)

2019-11-08 00:07:24
字体:
来源:转载
供稿:网友


PRivate void saveCroppedImage(Bitmap bmp) {        File file = new File("/sdcard/myFolder");        if (!file.exists())            file.mkdir();         file = new File("/sdcard/temp.jpg".trim());        String fileName = file.getName();        String mName = fileName.substring(0, fileName.lastIndexOf("."));        String sName = fileName.substring(fileName.lastIndexOf("."));         // /sdcard/myFolder/temp_cropped.jpg        String newFilePath = "/sdcard/myFolder" + "/" + mName + "_cropped" + sName;        file = new File(newFilePath);        try {            file.createNewFile();            FileOutputStream fos = new FileOutputStream(file);            bmp.compress(CompressFormat.JPEG, 50, fos);            fos.flush();            fos.close();        } catch (IOException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }     }

bitmap图片的保存,bitmap图片加水印后,保存在本地文件


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表