mardi 14 avril 2015

WP8 C# // Save image from web, in isolate storage

I know how to save an image in isolate storage :



private void addButton_Click(object sender, RoutedEventArgs e)
{
MemoryStream stream = new MemoryStream();
WriteableBitmap wb = new WriteableBitmap(myImage, null);
BitmapImage bi = new BitmapImage();

wb.SaveJpeg(stream, wb.PixelWidth, wb.PixelHeight, 0, 100);
stream.Seek(0, SeekOrigin.Begin);
string data = Convert.ToBase64String(stream.GetBuffer());

appSettings.Add("image", data);
}


I know how to load it :



private void loadImage_Click(object sender, RoutedEventArgs e)
{
byte[] imageBytes = Convert.FromBase64String(appSettings["image"].ToString());

MemoryStream ms = new MemoryStream(imageBytes);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(ms);
myImage.Source = bitmapImage;
}


But i don't know who to save an image in isolate storage from web url.


Thx for your help.


Aucun commentaire:

Enregistrer un commentaire