Wp7 相对Uri转化为Stream??
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(????);//希望把路径赋进去~
WriteableBitmap writeableBitmap = new WriteableBitmap(bitmapImage);
想把一张项目中的图片赋给WriteableBitmap,但是bitmapImage.SetSource()只能用Stream类型,有办法把相对Uri转化为Stream类吗??
[解决办法]
bitmapImage.uriSource="test.jpg";
[解决办法]
已解决~
StreamResourceInfo sri = null;
Uri uri = new Uri("/Model;component/image.png", UriKind.Relative);
sri = Application.GetResourceStream(uri);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.CreateOptions = BitmapCreateOptions.None;
bitmapImage.SetSource(sri.Stream);
WriteableBitmap writeableBitmap = new WriteableBitmap(bitmapImage);