windows phone 8 - WinRT: How to read images from the pictures library via an URI? -


trying read image stored in pictures library via uri image never displayed (in image control). reading same image via stream works (assuming app hat picture library capability declared of course). reading images application's data folder via uri works.

does know wrong?

here how (unsucessfully) try read image via uri:

var imagefile = (await knownfolders.pictureslibrary.getfilesasync()).firstordefault(); string imagepath = imagefile.path; uri urisource = new uri(imagepath); var bitmap = new bitmapimage(urisource); this.image.source = bitmap; 

here how sucessfully read same image via stream:

var imagefile = (await knownfolders.pictureslibrary.getfilesasync()).firstordefault(); bitmapimage bitmap; using (var stream = await imagefile.openreadasync()) {    bitmap = new bitmapimage();    await bitmap.setsourceasync(stream); } this.image.source = bitmap; 

i need read image via uri because fastest way read images , async nature, working data binding.

there no uri pictures library. you'll need storagefile , stream in.

the file uri use doesn't work because app doesn't have direct access pictureslibrary , cannot reference items there path. storagefile object provides brokered access locations app doesn't natively have permissions to.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -