c# - Windows phone picturebox -


i'm developing windows phone 8.1 application in c#. i'm using camera take picture. picture saved on device , i'm trying show in picturebox. have tested on htc phone , worked nice, when tried on nokia lumia picture never load. have idea how solve that?

here code sing take picture:

    private void snap_task_click(object sender, eventargs e)     {         cameracapturetask = new cameracapturetask();         cameracapturetask.completed += cameracapturetask_completed;         cameracapturetask.show();      }      void cameracapturetask_completed(object sender, photoresult e)     {         if (e.taskresult == taskresult.ok)         {             navigationservice.navigate(new uri("/slika.xaml?fotka=" + e.originalfilename, urikind.relative));          }     } 

and code try toload picture.

    public slika()     {         initializecomponent();         string slika = string.empty;         string slika2 = string.empty;         this.loaded += (s, e) =>         {              if (navigationcontext.querystring.trygetvalue("fotka", out slika))             {                  putanja = slika; /*"/resources/" + slika + ".png";/**/                  int x = putanja.length;                  if (x == 1)                 {                     putanja = "/resources/" + putanja + ".png";                     uriputanja = new uri(putanja, urikind.relative);                     fotka = new bitmapimage(uriputanja);                 }                 else                 {                     uriputanja = new uri(putanja, urikind.relative);                     porukatextbox.text = putanja;                     fotka = new bitmapimage(uriputanja);                 }             }             img1.source = fotka;          };      } 

ps

the loading local resources works fine on both phones, "else" part of if causing problems on nokia.

you saving image in camera roll folder in phone, try saving on memory card instead , try if works (you change in setting of phone , save new pictures on sd card) if works, try using photochoosertask in order image. hope following code you:

    using microsoft.phone.tasks;     using system.io;     using system.windows.media.imaging;     ...     photochoosertask selectphoto = null;     private void button1_click(object sender, routedeventargs e)     {         selectphoto = new photochoosertask();         selectphoto.completed += new eventhandler(selectphoto_completed);         selectphoto.show();     }     void selectphoto_completed(object sender, photoresult e)     {         if (e.taskresult == taskresult.ok)         {             binaryreader reader = new binaryreader(e.chosenphoto);             image1.source = new bitmapimage(new uri(e.originalfilename));         }     } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -