我有一个带有全景图和一个按钮的简单页面,该按钮必须更改全景图的背景图片。原始图片是1200x800。如果我使用资源中的图片,一切都很好:
Uri uri = new Uri("Resources/Panorama.png", UriKind.Relative);
var bitmap2 = new BitmapImage(uri);
// here from debugging: bitmap2.CreateOptions == DelayCreation, bitmap2.PixelWidth == 0 and bitmap2.PixelHeight == 0
var lcBrush2 = new ImageBrush() {
Stretch = Stretch.Fill,
ImageSource = bitmap2
};
panoMain.Background = lcBrush2;
但是如果我从独立存储中拍照:
var picStream = ...getting a stream of file....;
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(picStream);
// here from debugging: bitmap.PixelWidth == 1200 and bitmap.PixelHeight == 800
var lcBrush = new ImageBrush() {
Stretch = Stretch.Fill,
ImageSource = bitmap
};
panoMain.Background = lcBrush;
然后图片缩小到480x800
我做错了什么?或者它是来自MS的错误?