geolocation - Windows Phone 7.1 -Saving path of photo taken by cameraCaputreTask -


i'm building app should- among other things, let user capture picture , save picture , other info (like location of picture taken -using gps of phone , etc...) on database.

im using string save pictures database. far good. problem after user has captured picture can not find path of picture anywhere (in order display later user ) i know can display picture if use image , not string not able save db.

also used picture string (which should path of picture ) primarykey column in table , if string null problem sure.

after checking on internet found out cannot use geocoordinatewatcher (for gps) on emulator had use random place. led me thinking picture taken emulator may not have path??

part of code: (the event of camera , bottun saves everyting db)

   void c_completed(object sender, photoresult e)     {         if (e.taskresult == taskresult.ok)         {             messagebox.show(e.chosenphoto.length.tostring());               //code display photo on page in image control named myimage.             bitmapimage bmp = new system.windows.media.imaging.bitmapimage();             bmp.setsource(e.chosenphoto);             myimage.source = bmp;//display picture right after taking it. before saving db             p.urlimage = bmp.urisource.absolutepath;//do not work!          }     }      private void savetodb_click(object sender, routedeventargs e)     {          p.description = desriptionlist.selectedvalue.tostring();//description of pic         p.date = datetime.today;//date picture taken          geocoordinatewatcher mywatcher = new geocoordinatewatcher();         var myposition = mywatcher.position;         p.location = myposition.location.altitude+" "+myposition.location.latitude;//do not work emulator         p.location = "some on rainbow";         mainpage.m._bl.addpic(p);//add pic db         messagebox.show("added successfully! :)");         navigationservice.navigate(new uri(@"/intro.xaml", urikind.relative));//go page     } } 

my class:

  [table] public class picture {     public picture()     {      }      public picture(string l, string d, string url, datetime da)     {         location = l;         description = d;         urlimage = url;         date = da;     }     string location;      [column]     public string location     {         { return location; }         set { location = value; }     }     string urlimage;      [column (isprimarykey=true)]     public string urlimage     {         { return urlimage; }         set { urlimage = value; }     }     datetime date;     [column]     public datetime date     {         { return date; }         set { date = value; }     }     string description;     [column]     public string description     {         { return description; }         set { description = value; }     } } 

}

anyway- know if can path in way... , also- if cant path- windows have "better" emulator? emulator cant , quite annoying giving fact dont have wp check apps on.. thanks!

you stream of taken image in e.chosenphoto. need save that.

var imagebytes = new byte[e.chosenphoto.length]; e.chosenphoto.read(imagebytes, 0, imagebytes.length);  using (var isofile = isolatedstoragefile.getuserstoreforapplication()) {   using (var stream = isofile.createfile("myimage.jpg")) {     stream.write(imagebytes, 0, imagebytes.length);   } } 

edit:

regarding emulator, there nothing wrong or limited it.

the taken image stored in temp file may vanish later on that's why need save locally in isolated storage if want display image again.

regarding gps, can use additional tools (just click on '>>' button on right side of emulator set various settings find on actual device such accelerometer, location, network, etc.. geowatcher can define set of points on map played if device's actual gps location changing.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -