Basically I am using Visual Studio/Expression Blend to do my app. Its works as in the user can select the picture that he/she wants to edit and after editing the user just had to click the save button and the edited image will be save in isolated storage but I just could not command the save button to save the image into the isolated storage so hope someone will help me with it with some sample codes thanks a lot in advance.
I tried with the code below but when I press the save button there's a null reference error. My thinking is that when you press save, the app does not know which image to save into the isolated storage and not really sure my thinking is right. Can anyone please help me with this. Thanks a lot.
private void btnSave_Click(object sender, RoutedEventArgs e)
{
String tempJPEG = "TempJPEG";
var myStore = IsolatedStorageFile.GetUserStoreForApplication();
if (myStore.FileExists(tempJPEG))
{
myStore.DeleteFile(tempJPEG);
}
IsolatedStorageFileStream myFileStream = myStore.CreateFile(tempJPEG);
Uri uri = new Uri("TestImage.jpg", UriKind.Relative);
StreamResourceInfo sri = Application.GetResourceStream(uri);
BitmapImage bitmap = new BitmapImage();
bitmap.CreateOptions = BitmapCreateOptions.None;
bitmap.SetSource(sri.Stream);
WriteableBitmap wb = new WriteableBitmap(bitmap);
Extensions.SaveJpeg(wb, myFileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
myFileStream.Close();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…