Reputation: 3754
I have to save bitmap drawn on canvas to be saved in my own folder.
String imgSaved = MediaStore.Images.Media.insertImage(
getContentResolver(), drawView.getDrawingCache(),
UUID.randomUUID().toString() + ".png", "drawing");
How should i give a path to the directory? e.g. "/sdcard/MyPictures/"
Upvotes: 5
Views: 17980
Reputation: 152
Try creating File object for your desired path
File mFile = new File("/sdcard/tmp");
String imgSaved=MediaStore.Images.Media.insertImage(getContentResolver(),mFile.getAbsolutePath(),UUID.randomUUID().toString()+".png", "drawing");
Check out this link for reference.
Upvotes: 2
Reputation: 8899
Use Bitmap.compress to save as JPG or PNG at desired location
File file = new File(yourpath, "yourfile.jpg");
FileOutputStream out = new FileOutputStream(filename);
yourbitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
Note: 90
is the compression
where 100
means no compression. It works for JPG and not for PNG. Don't forget to handle exceptions
Upvotes: 3