android - convert the bitmap file (of a cuptured image) to a path file -




the photo parameter bitmap , checked , shows cuptured image

how can convert bitmap path able send attachment mail

this code :

protected void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);     setcontentview(r.layout.opencvhc);     imgphoto = (imageview) findviewbyid(r.id.imgphoto);     bundle extras = getintent().getextras();     if (extras != null) {         bm = (bitmapdataobject) getintent().getserializableextra("photo"); //obtaining data         bitmap = bm.getbip();         imgphoto.setimagebitmap(bitmap);     }      checkmood = (button) findviewbyid(r.id.checkmood);     check = (button) findviewbyid(r.id.check);     txtview = (textview) findviewbyid(r.id.txt);   }  public void checkclick(view view) throws ioexception {      string file = mediastore.images.media.insertimage(getcontentresolver(), bitmap, "file", null);     //uri screenshoturi = uri.parse(file);     toast.maketext(opencvhc.this, file, toast.length_short).show();     final intent emailintent1 = new intent(android.content.intent.action_send);     emailintent1.putextra(intent.extra_email, new string[]{"comfplatform@gmail.com"});     emailintent1.putextra(intent.extra_subject, "image processing picture");     emailintent1.setflags(intent.flag_activity_new_task);     // emailintent1.putextra(intent.extra_stream, screenshoturi);     emailintent1.putextra(intent.extra_text, "" +             "we checked photo ecg-leads  \n 1) : " +             "\n image proccessing ___ ");     emailintent1.settype("image/png");     try {         startactivity(intent.createchooser(emailintent1, "send mail..."));     } catch (android.content.activitynotfoundexception ex) {         toast.maketext(opencvhc.this, "there no email clients installed.", toast.length_short).show();     }  } 

}

see solution , don't forget check "write_external_storage" permission before writing file. reference : android: saving bitmap external memory

   public void saveimagetoexternalstorage(bitmap finalbitmap) {     string root =environment.getexternalstoragepublicdirectory(environment.directory_pictures).tostring();     file mydir = new file(root + "/saved_images");     mydir.mkdirs();     random generator = new random();     int n = 10000;     n = generator.nextint(n);     string fname = "image-" + n + ".jpg";     file file1 = new file(mydir, fname);     if (file1.exists())         file1.delete();     try {         fileoutputstream out = new fileoutputstream(file1);         finalbitmap.compress(bitmap.compressformat.jpeg, 90, out);         out.flush();         out.close();     }     catch (exception e) {         e.printstacktrace();     }       // tell media scanner new file     // available user.     mediascannerconnection.scanfile(this, new string[] { file1.tostring() },                null,             new mediascannerconnection.onscancompletedlistener() {                 public void onscancompleted(string path, uri uri) {                     log.i("externalstorage", "scanned " + path + ":");                     log.i("externalstorage", "-> uri=" + uri);                 }             });  } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -