Application in android related to camera -
in photographic camera application have image-button,image-view , 2 button confirm , save.on first display image-button visible , others invisible, done coding how photographic camera on click of image button , got image in image-view , on click of confirm button save appear, in save on-click want save image captured in image-view in particular file on sd-card serial naming loop done in digital cam ".png" extension.please help me .and in advance
first have homecoming bitmap image captured , utilize method on button click i'm using tho.
void save() { if (null != view.getdrawable()) { view.setdrawingcacheenabled(true); view.builddrawingcache(); save = view.getdrawingcache(); final file mydir = new file(folder); mydir.mkdirs(); final random generator = new random(); int n = 10000; n = generator.nextint(n); final string fname = "styleme-" + n + ".png"; file = new file(mydir, fname); if (file.exists()) file.delete(); seek { final fileoutputstream out = new fileoutputstream(file); save.compress(bitmap.compressformat.png, 100, out); out.flush(); out.close(); sendbroadcast(new intent(intent.action_media_mounted, uri.parse("file://" + environment.getexternalstoragedirectory()))); toast.maketext(getapplication(), "image saved", toast.length_short).show(); } grab (final exception e) { toast.maketext(getapplication(), "something went wrong check if have plenty memory", toast.length_long).show(); } } else { final toast tst = toast.maketext(getapplication(), "please select image first", toast.length_long); tst.setgravity(gravity.center, 0, 0); tst.show(); } view.setdrawingcacheenabled(false); }
here i'm getting image view cashes , save png
have delete if statement
, alter save bitmap name save.compress(bitmap.compressformat.png, 100, out);` ,
void save() { final file mydir = new file(folder); mydir.mkdirs(); final random generator = new random(); int n = 10000; n = generator.nextint(n); final string fname = "styleme-" + n + ".png"; file = new file(mydir, fname); if (file.exists()) file.delete(); seek { final fileoutputstream out = new fileoutputstream(file); save.compress(bitmap.compressformat.png, 100, out); \\ alter save bitmap name out.flush(); out.close(); sendbroadcast(new intent(intent.action_media_mounted, uri.parse("file://" + environment.getexternalstoragedirectory()))); toast.maketext(getapplication(), "image saved", toast.length_short).show(); } grab (final exception e) { toast.maketext(getapplication(), "something went wrong check if have plenty memory", toast.length_long).show(); } }
` , here folder string
string folder = "/sdcard/pictures/styleme";
and static file file;
, p.s method automatically tell gallery scan new files , without restarting phone or doing manually . take reply if seek , vote sure. edit: add together in manifest <uses-permission android:name="android.permission.write_external_storage" />
android
No comments:
Post a Comment