【发布时间】:2013-09-26 09:27:51
【问题描述】:
我在 Windows 运行时环境中将 Image 实例添加到 Canvas 中,当在 140 和 180 比例分辨率显示时,我的图像不断放大,它在比例分辨率 100 时看起来很完美。我尝试创建 3 个 PNG 图像,每个比例尺都有一个:100、140、180,但它仍然按比例放大它们,它们看起来很模糊。我在青色背景上创建了一个带有 4 个黑色像素的测试图像,然后从模拟器中截取了一张截图,看看图像是如何模糊的,我的原始图像只有 4 个完美的黑色像素:
我尝试更改我的 Image 对象的拉伸模式,但它什么也没做。我正在使用此代码在运行时添加图像:
var bitmapImage = new BitmapImage();
StorageFile bitmapFile = await StorageFile.GetFileFromApplicationUriAsync(imageUri);
await bitmapImage.SetSourceAsync(await bitmapFile.OpenReadAsync());
Image image = new Image{ Source = bitmapImage};
image.SetValue(Canvas.LeftProperty, x);
image.SetValue(Canvas.TopProperty, y);
canvas.Children.Add(image);
如何让图像在画布中完美地绘制像素而不进行缩放,并且在我想要的确切 x/y 坐标处?
【问题讨论】:
标签: c# image canvas windows-runtime winrt-xaml