简体   繁体   中英

How to download a Image from a Path and save it as a BitmapImage

Does anyone know, how to download a Image from a path like "C:/Data/Users/Public/Pictures/Camera Roll/Picture.jpg" (in a Windows Phone 8.1 Device) and save it as a BitmapImage? I tried it with this, but after that I don't know, how to save the StorageFile as a BitmapImage.

StorageFolder picturesFolder = KnownFolders.CameraRoll;

StorageFile storageFile = await picturesFolder.GetFileAsync(fileName);

I hope someone can help me.

Cristian

Create a stream out of the file and open it via SetSourceAsync ( here ).

using (var stream = await storageFile.OpenReadAsync())
{
  await bitmap.SetSourceAsync(stream);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM