C# Graphics中有关绘图质量的几个Mode

 

一、CompositingMode

获取一个值,该值指定如何将合成图像绘制到此 Graphics复合模式确定从源映像的像素是覆盖(SourceCopy)还是组合(SourceOver, 需要使用半透明、混合叠加效果时使用)使用背景像素默认值为 SourceOver

该属性适用于 适用于.NET Framework 4.7.2, 4.7.1, 4.7, 4.6.2, 4.6.1, 4.6, 4.5.2, 4.5.1, 4.5, 4.0, 3.5, 3.0, 2.0, 1.1

不应使用CompositingMode属性值为SourceCopyTextRenderingHint属性设置为ClearTypeGridFit。 可能会发生异常或图像可能无法正确呈现。

 

二、CompositingQuality

获取或设置绘制到此 Graphics 的合成图像的呈现质量。组合的情况下质量决定将合成图像的呈现质量级别。

CompositingQuality Enum

AssumeLinear 4

假定线性值。

Default 0

默认质量。

GammaCorrected 3

使用灰度校正。

HighQuality 2

高质量、低速度复合。

HighSpeed 1

高速度、低质量。

Invalid -1

无效质量。

Compositing is done during rendering when the source pixels are combined with the destination pixels to produce the resultant pixels.
The quality of compositing directly relates to the visual quality of the output and is inversely proportional to the render time. The higher the quality, the slower the render time. This is because the higher the quality level, the more surrounding pixels need to be taken into account during the composite. The linear quality setting (AssumeLinear) compromises by providing better quality than the default quality at a slightly lower speed.
 

三、InterpolationMode

The interpolation mode determines how intermediate values between two endpoints are calculated.

 

四、SmoothingMode

平滑模式指定直线、 曲线和已填充区域的边缘是否使用平滑处理 (也称为抗锯齿)。 一个例外是路径渐变画笔不遵守平滑模式。 使用填充的区域PathGradientBrush呈现相同的方式 (别名) 而不考虑SmoothingMode属性。

 

五、TextRenderingHint

The text rendering hint specifies whether text renders with antialiasing.

Note:

You should not use a CompositingMode property value of SourceCopy when the TextRenderingHint property is set to ClearTypeGridFit. An exception could occur or the image may not render correctly.

 

六、TextContrast

The gamma correction value used for rendering antialiased and ClearType text.

private void ChangeTextRenderingHintAndTextContrast(PaintEventArgs e)
{

    // Retrieve the graphics object.
    Graphics formGraphics = e.Graphics;

    // Declare a new font.
    Font myFont = new Font(FontFamily.GenericSansSerif, 20, FontStyle.Regular);

    // Set the TextRenderingHint property.
    formGraphics.TextRenderingHint =  System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;

    // Draw the string.
    formGraphics.DrawString("Hello World", myFont, Brushes.Firebrick, 20.0F, 20.0F);

    // Change the TextRenderingHint property.
    formGraphics.TextRenderingHint =  System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

    // Draw the string again.
    formGraphics.DrawString("Hello World", myFont, Brushes.Firebrick, 20.0F, 60.0F);

    // Set the text contrast to a high-contrast setting.
    formGraphics.TextContrast = 0;

    // Draw the string.
    formGraphics.DrawString("Hello World", myFont, 
        Brushes.DodgerBlue, 20.0F, 100.0F);

    // Set the text contrast to a low-contrast setting.
    formGraphics.TextContrast = 12;

    // Draw the string again.
    formGraphics.DrawString("Hello World", myFont,  Brushes.DodgerBlue, 20.0F, 140.0F);

    // Dispose of the font object.
    myFont.Dispose();

}

 

 

 

参考资料

MSDN .NET 4.7.2, 18.9.20

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值