【问题标题】:DrawImage filtering when drawing rotated image on WPF DrawingContext在 WPF DrawingContext 上绘制旋转图像时的 DrawImage 过滤
【发布时间】:2012-06-21 08:28:03
【问题描述】:

我在控件上绘制图像,通常仅旋转几度。这使得适当的过滤很重要,但我看到的伪影看起来像是最近邻问题。在哪里可以设置绘制图像时使用的过滤器?

图像大于屏幕上的最终尺寸。

    private void drawRotatedImage( DrawingContext dc , double width_px , double x , double y , double angle )
    {
        dc.PushTransform( new TranslateTransform(x,y) );
        dc.PushTransform( new RotateTransform(angle) );
        double scale = width_px / image.Width;
        Rect rr = new Rect( -image.Width*0.5*scale , -image.Height*0.5*scale , image.Width*scale , image.Height*scale );
        dc.DrawImage( image , rr );
        dc.Pop();
        dc.Pop();
    }

【问题讨论】:

    标签: wpf drawimage drawingcontext


    【解决方案1】:

    如果您是在 .NET 4 中编写代码,那么您需要将过滤器升级到更高质量的 Fant 过滤器。

    通过在 Window 或特定元素上添加附加属性来做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-09
      • 2012-05-02
      • 1970-01-01
      • 2014-04-21
      • 1970-01-01
      • 2015-04-16
      • 2012-12-08
      相关资源
      最近更新 更多