WP7中的图片存取与读取问题(独立文件存储)

staru 2012-01-17
C# code
我现在有一个image(假如叫:PasswordCardImage),从task(那个可以选择或者拍照的API)中读取图片

private void camera_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult==TaskResult.OK)
            {        
                //保存图片
                WriteableBitmap wb = new WriteableBitmap(100, 100);
                wb.SetSource(e.ChosenPhoto);
                PasswordCardImage.Source = wb;
                DB.DBtext1(wb);//保存图片
                MessageBox.Show("保存成功");
               //pnl_AddGameNum.Visibility = Visibility.Collapsed;
            }
      }

这样读取是可以的,image上也显示图片了。将其保存到独立文件存储空间中用得方法是
//将writebitmap保存为图片
            public  static void DBtext1(WriteableBitmap wb)
            {
                IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
                using (Stream stream = storage.OpenFile("123.jpg", FileMode.Create))
                {
                    Extensions.SaveJpeg(wb, stream, 300, 300, 0, 100);
                }
            
            }

然后用以下方法读取:
//读取独立存储器中的图片
            public static WriteableBitmap  DBtext2()
            {
                WriteableBitmap wb = new WriteableBitmap(300, 300);
                IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
                using (Stream stream = storage.OpenFile("123.jpg", FileMode.Open))
                {
                    Extensions.LoadJpeg(wb, stream);
                }
                return wb;
               
            }

最后在前台显示这张图片是这样的:
PasswordCardImage.Source =DB.DBtext2();



但是这样就显示不出来了,好像是image不见了。image那里变为了一个“缺口”。

求大神们指教。。。
Global site tag (gtag.js) - Google Analytics