【发布时间】:2014-02-04 12:23:20
【问题描述】:
我希望能够拍照、显示并保留位置,以便我可以将其保存到记录中并能够在以后显示。
我已经能够使用代码很好地显示它
BitmapImage bmp = newBitmapImage();
bmp.SetSource(e.ChosenPhoto);
myImage.Source = bmp2;
当 myImage 是正在显示的图像,并且 e 是 PhotoResult 对象时。但是,由于我需要将其保存在记录中,因此我尝试使用此代码根据位置显示照片。
string imageLoc = e.OriginalFileName;
Uri imageUri = new Uri(imageLoc, UriKind.Relative);
StreamResourceInfo resourceInfo = Application.GetResourceStream(imageUri);
BitmapImage bmp = BitmapImage();
bmp.SetSource(resourceInfo.Stream);
myImage.Source = bmp;
当我运行此代码时,我得到一个 System.NullReferenceException。我认为这与 Application.GetResourceStream 有关,但我不确定发生了什么问题。
为澄清起见,我希望能够从某个位置加载和显示照片,例如 'C:\Data\Users\Public\Pictures\Camera Roll\imageExample.jpg'
【问题讨论】:
标签: c# windows-phone-7 windows-phone-8 mobile-application