ScrollViewer中的图像失真

时间:2015-05-15 23:45:11

标签: c# wpf

我遇到一个奇怪的问题,如果我将窗口调整到特定大小,会导致图像失真。我假设图像正在滚动查看器中定位到子像素位置,但我不确定如何解决这个问题。

我正在使用Scaletransform,但如果比例设置为1,则会出现当前问题。

如果您查看下面屏幕截图中的文字,您会看到文字略有失真,如果我按单个像素重新调整窗口大小,则失真会消失,如备用屏幕截图所示。

像素失真

Pixel Distortion

无失真

No Distortion

XAML代码

<ScrollViewer x:Name="scrollViewer"
          Background="#282828"
          Focusable="False"
          Grid.Column="2"
          HorizontalScrollBarVisibility="Visible"
          VerticalScrollBarVisibility="Visible" SnapsToDevicePixels="True">

<Border BorderBrush="Red" BorderThickness="1">
    <Grid Name="grid" RenderTransformOrigin="0.5,0.5"      SnapsToDevicePixels="True">
        <Grid.LayoutTransform>
            <TransformGroup>
                <ScaleTransform x:Name="scaleTransform" CenterX="0.5" CenterY="0.5" />
            </TransformGroup>
        </Grid.LayoutTransform>


        <Image Name="img" HorizontalAlignment="Left" VerticalAlignment="Top"
               IsHitTestVisible="False"
               RenderOptions.BitmapScalingMode="NearestNeighbor"
               SnapsToDevicePixels="True"
               Stretch="Uniform" />

    </Grid>
</Border>
</ScrollViewer>

1 个答案:

答案 0 :(得分:1)

只是预感:您是否尝试过应用UseLayoutRounding

相关问题