C# 在wp7中读取本地图像
在我的应用程序中,我需要打开一个本地图像进行裁剪。我尝试将图像的路径设置为BitmapImage的源,但出现了一个错误。如何读取本地图像并将其分配给WP Mango中的BitmapImageC# 在wp7中读取本地图像,c#,windows-phone-7.1,C#,Windows Phone 7.1,在我的应用程序中,我需要打开一个本地图像进行裁剪。我尝试将图像的路径设置为BitmapImage的源,但出现了一个错误。如何读取本地图像并将其分配给WP Mango中的BitmapImage private WriteableBitmap ReadLocalImage(string Uri) { StreamResourceInfo sri = null; Uri uri = new Uri(Uri, UriKind.Rela
private WriteableBitmap ReadLocalImage(string Uri)
{
StreamResourceInfo sri = null;
Uri uri = new Uri(Uri, UriKind.Relative);
sri = Application.GetResourceStream(uri);
BitmapImage bitmap = new BitmapImage();
bitmap.CreateOptions = BitmapCreateOptions.None;
bitmap.SetSource(sri.Stream);
WriteableBitmap wb = new WriteableBitmap(bitmap);
return wb;
}
使用此方法读取局部图像