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属性值为SourceCopy时TextRenderingHint属性设置为ClearTypeGridFit。 可能会发生异常或图像可能无法正确呈现。
二、CompositingQuality
获取或设置绘制到此 Graphics 的合成图像的呈现质量。组合的情况下质量决定将合成图像的呈现质量级别。
CompositingQuality Enum
AssumeLinear | 4 |
假定线性值。 |
Default | 0 |
默认质量。 |
GammaCorrected | 3 |
使用灰度校正。 |
HighQuality | 2 |
高质量、低速度复合。 |
HighSpeed | 1 |
高速度、低质量。 |
Invalid | -1 |
无效质量。 |
三、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
没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· C# 深度学习:对抗生成网络(GAN)训练头像生成模型
· .NET 适配 HarmonyOS 进展
· 手把手教你更优雅的享受 DeepSeek
· 腾讯元宝接入 DeepSeek R1 模型,支持深度思考 + 联网搜索,好用不卡机!
· AI工具推荐:领先的开源 AI 代码助手——Continue
· 探秘Transformer系列之(2)---总体架构
· V-Control:一个基于 .NET MAUI 的开箱即用的UI组件库
2016-09-20 注册测绘师考试
2016-09-20 无人机DLG生产作业流程