windows-phone-7 – 如何将图像从隔离存储加载到Windows Phone上
发布时间:2020-12-14 02:54:33 所属栏目:Windows 来源:网络整理
导读:我正在使用此代码将图像存储到相机操作完成时的隔离存储中. void camera_Completed(object sender,PhotoResult e){ BitmapImage objImage = new BitmapImage(); //objImage.SetSource(e.ChosenPhoto); //Own_Image.Source = objImage; using (var isolatedSt
我正在使用此代码将图像存储到相机操作完成时的隔离存储中.
void camera_Completed(object sender,PhotoResult e) { BitmapImage objImage = new BitmapImage(); //objImage.SetSource(e.ChosenPhoto); //Own_Image.Source = objImage; using (var isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { fnam = e.OriginalFileName.Substring(93); MessageBox.Show(fnam); if (isolatedStorage.FileExists(fnam)) isolatedStorage.DeleteFile(fnam); IsolatedStorageFileStream fileStream = isolatedStorage.CreateFile(fnam); BitmapImage bitmap = new BitmapImage(); bitmap.SetSource(e.ChosenPhoto); WriteableBitmap wb = new WriteableBitmap(bitmap); wb.SaveJpeg(fileStream,wb.PixelWidth,wb.PixelHeight,100,100); MessageBox.Show("File Created"); fileStream.Close(); } } 现在我想从隔离存储中取出图像并将其显示在我的图像控件中. 可能吗? 解决方法
是的.您可以使用此功能从IsolatedStorage加载图像:
private static BitmapImage GetImageFromIsolatedStorage(string imageName) { var bimg = new BitmapImage(); using (var iso = IsolatedStorageFile.GetUserStoreForApplication()) { using (var stream = iso.OpenFile(imageName,FileMode.Open,FileAccess.Read)) { bimg.SetSource(stream); } } return bimg; } 用法: ImageControl.Source = GetImageFromIsolatedStorage(fnam); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- exchange-2010 – 将电子邮件从Exchange(2010 / SBS2011)迁
- 练习:for循环和while循环
- windows-server-2012 – 在SVCHOST / Workstation服务上使用
- win10 mars xlog编译
- windows-server-2012 – 赢取2012 AD安全组权限
- Windows下面startup.bat启动Tomcat偶发死锁问题
- 如何在Windows 10中安装atari-py?
- windows-server-2008 – Linux管理员的Windows服务器管理资
- windows-7 – Windows 7上频繁的NTP同步时间
- 在windows dos shell下使用参数执行Perl脚本的正确命令行是