首页 > 系统 > Android > 正文

Android 拍照剪裁,获取相册图片,上传照片至服务端

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

保存图片到sd卡

public static void savePhotoToSDCard(Bitmap photoBitmap, String path, String photoName){    if (checkSDCardAvailable())    {        File dir = new File(path);        if (!dir.exists())        {            dir.mkdirs();        }        File photoFile = new File(path, photoName);        FileOutputStream fileOutputStream = null;        try        {            fileOutputStream = new FileOutputStream(photoFile);            if (photoBitmap != null)            {                if (photoBitmap.comPRess(Bitmap.CompressFormat.PNG, 100, fileOutputStream))                {                    fileOutputStream.flush();                }            }        }        catch (FileNotFoundException e)        {            photoFile.delete();            e.printStackTrace();        }        catch (IOException e)        {            photoFile.delete();            e.printStackTrace();        }        finally        {            try            {                fileOutputStream.close();                photoBitmap.recycle();            }            catch (Exception e)            {                e.printStackTrace();            }        }    }}


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