【问题标题】:Disable antialiasing for Graphics.FillRectangle?禁用 Graphics.FillRectangle 的抗锯齿?
【发布时间】:2013-11-22 08:07:03
【问题描述】:

我正在使用Graphics 绘制一个矩形:

// x and y are arbitrary integers or floats. Doesn't matter!
Graphics.FillRectangle(Brushes.Black, x, y, 5, 5);

这会产生一个带有 antialiased 边框的黑色矩形。 如何在绘制矩形时禁用抗锯齿功能?

以下不起作用:

Graphics.SmoothingMode = SmoothingMode.HighSpeed;
Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;

【问题讨论】:

    标签: c# winforms


    【解决方案1】:

    您所看到的与用于在对角线上填充楼梯的“平滑”略有不同 - 而是将矩形的边缘定位在像素的名义中心。

    你需要使用

    Graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed 
    

    (或其他一些枚举值,取决于您想要的精确效果)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-03
      • 2011-08-30
      • 2011-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-18
      相关资源
      最近更新 更多