【发布时间】:2015-09-16 22:44:38
【问题描述】:
我是 WPF 新手,面临以下问题。 我正在显示一个位图,xaml:
<ControlTemplate x:Key="MyEditorImageTemplate">
<Image VerticalAlignment="Top" Margin="3,1,0,0"
RenderOptions.BitmapScalingMode="NearestNeighbor"
Stretch="None">
<Image.Source>
<MultiBinding Converter="{StaticResource MyEditorConverter}">
<Binding Path="....." />
Bitmap 来自 BitmapSource,提供以下方式:
Bitmap^ bitmap = System::Drawing::Image::FromHbitmap((IntPtr)aBmp);
IntPtr hbmp = bitmap->GetHbitmap();
BitmapSource bs =
Imaging::CreateBitmapSourceFromHBitmap(hbmp,
System::IntPtr::Zero,
Int32Rect(0,0,nWidth,nHeight),
BitmapSizeOptions::FromEmptyOptions());
现在这工作正常,直到我将窗口缩放级别设置为 100%。 如果我在 Windows 中将其更改为 125%:
位图也在 GUI 上缩放。
我知道这 - 有点 - 预期,但有什么方法我仍然显示它 1-1 像素大小,忽略 Windows 缩放设置?
【问题讨论】: