博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【转】Graphics 关于呈现质量与合成模式
阅读量:7172 次
发布时间:2019-06-29

本文共 5135 字,大约阅读时间需要 17 分钟。

GDI+相关的作图,每种语言都有其自身的封装类,但本质上是一样的,下面这篇文章写的非常好,对于C#的Graphics类也是使用的,所以转载了,原文在这里:

相关内容有:


 
IGPGraphics.SmoothingMode;            { 绘图质量 }IGPGraphics.InterpolationMode;        { 插补模式 }IGPGraphics.CompositingMode;          { 前景色与背景色的合成混合模式 }IGPGraphics.CompositingQuality;      { 图像合成质量 }IGPGraphics.PixelOffsetMode;          { 像素的偏移模式 }{ 文本的呈现质量要用 }IGPGraphics.TextRenderingHint;        { 文本呈现模式 }IGPGraphics.TextContrast;            { 文本灰度校正值(消除锯齿和 ClearType 文本的伽玛值校正) }
相关参数:

 
SmoothingMode { 对直线、曲线和已填充区域的边缘采用锯齿消除功能, 它不能控制路径渐变画笔 }Invalid    // 一个无效模式  Default    // 不消除锯齿, 等效于 HighSpeed、NoneHighSpeed  // 不消除锯齿  HighQuality // 消除锯齿, 等效于 AntiAliasNone        // 不消除锯齿  AntiAlias  // 消除锯齿InterpolationMode { 插补模式确定如何计算两个像素点之间的中间值 }Invalid            // 等效于 QualityMode 枚举的 Invalid 元素.Default            // 默认模式.Low                // 低质量插值法.High                // 高质量插值法.Bilinear            // 双线性插值法; 不进行预筛选; 将图像收缩为原始大小的 50% 以下时此模式不适用. Bicubic            // 双三次插值法; 不进行预筛选; 将图像收缩为原始大小的 25% 以下时此模式不适用.NearestNeighbor    // 最临近插值法.HighQualityBilinear // 高质量的双线性插值法; 执行预筛选以确保高质量的收缩. HighQualityBicubic  // 高质量的双三次插值法; 执行预筛选以确保高质量的收缩; 可产生质量最高的转换图像.CompositingMode { 颜色合成模式 }SourceOver  // 与背景色混合; 该混合由透明度确定SourceCopy  // 改写背景色 CompositingQuality { 图像合成时, 源像素与目标像素和合成方式 }Invalid        // 无效质量 Default        // 默认质量 HighSpeed      // 高速度、低质量 HighQuality    // 高质量、低速度复合 GammaCorrected // 使用灰度校正 AssumeLinear  // 假定线性值PixelOffsetMode { 像素偏移模式 }Invalid    // 无效模式.Default    // 默认模式.HighSpeed  // 高速度、低质量呈现.HighQuality // 高质量、低速度呈现.None        // 没有任何像素偏移.Half        // 像素在水平和垂直距离上均偏移 -0.5 个单位, 以进行高速锯齿消除.
SmoothingMode 测试:
o_09122301.png

 
uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var   Graphics: IGPGraphics;   Pen: IGPPen;   Rect: TGPRectF;   i: Integer;begin   Graphics := TGPGraphics.Create(Handle);   Pen := TGPPen.Create($FFB22222, 4);   Rect.Initialize(ClientWidth * 3/8, ClientHeight * 3/8, ClientWidth / 4, ClientHeight / 4);   for i := 0 to 4 do   begin     Graphics.SmoothingMode := TGPSmoothingMode(i);     Graphics.DrawEllipse(Pen, Rect);     Rect.Inflate(ClientWidth / 14, ClientHeight / 14);   end;end;
InterpolationMode 测试:
o_09122303.png

 
uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var   Graphics: IGPGraphics;   Image: IGPImage;   Rect: TGPRectF;   i: Integer;begin   Graphics := TGPGraphics.Create(Handle);   Image := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');   Rect.Initialize(10, 10, Image.Width * 0.5, Image.Height * 0.5);   for i := 0 to 7 do   begin     Graphics.InterpolationMode := TGPInterpolationMode(i);     Graphics.DrawImage(Image, Rect);     Rect.Offset(Rect.Width + 10, 0);     if Rect.X + Rect.Width > ClientWidth then     begin       Rect.X := 10;       Rect.Offset(0, Rect.Height + 10);     end;   end;end;procedure TForm1.FormResize(Sender: TObject);begin   Repaint;end;
CompositingMode 测试:
o_09122302.png

 
uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var   Graphics: IGPGraphics;   Brush: IGPLinearGradientBrush;   Rect: TGPRect;begin   Graphics := TGPGraphics.Create(Handle);   Rect.Initialize(20, 20, 200, 60);   Brush := TGPLinearGradientBrush.Create(Rect, $FFA52A2A, $FFFFFF00, 0);   Graphics.CompositingMode := CompositingModeSourceOver; //默认模式   Graphics.FillRectangle(Brush, Rect);   Brush := TGPLinearGradientBrush.Create(Rect, $80A52A2A, $80FFFF00, 0);   Graphics.CompositingMode := CompositingModeSourceOver;   Rect.Offset(0, 20 + Rect.Height);   Graphics.FillRectangle(Brush, Rect);   Graphics.CompositingMode := CompositingModeSourceCopy;   Rect.Offset(0, 20 + Rect.Height);   Graphics.FillRectangle(Brush, Rect);end;
CompositingQuality 测试:
o_09122304.png

 
uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var   Graphics: IGPGraphics;   Image: IGPImage;   Rect: TGPRectF;   Brush: IGPSolidBrush;   i: Integer;begin   Graphics := TGPGraphics.Create(Handle);   Image := TGPImage.Create('C:\GdiPlusImg\Grapes.jpg');   Rect.Initialize(10, 10, Image.Width * 0.75, Image.Height * 0.75);   Brush := TGPSolidBrush.Create($800000FF);   for i := 0 to 4 do   begin     Graphics.CompositingQuality := TGPCompositingQuality(i);     Graphics.DrawImage(Image, Rect);     Graphics.FillRectangle(Brush, Rect);     Rect.Offset(Rect.Width + 10, 0);     if Rect.X + Rect.Width > ClientWidth then     begin       Rect.X := 10;       Rect.Offset(0, Rect.Height + 10);     end;   end;end;procedure TForm1.FormResize(Sender: TObject);begin   Repaint;end;
PixelOffsetMode 测试:
o_09122305.png

 
uses GdiPlus;procedure TForm1.FormPaint(Sender: TObject);var   Graphics: IGPGraphics;   BrushBack: IGPHatchBrush;   Brush: IGPSolidBrush;   Rect: TGPRectF;   i: Integer;begin   Graphics := TGPGraphics.Create(Handle);   BrushBack := TGPHatchBrush.Create(HatchStyleCross, $FFD0D0D0, $FFFFFFFF);   Graphics.FillRectangle(BrushBack, TGPRect.Create(ClientRect));   Rect.Initialize(0.34, 1, 5.1, 1.3);   Brush := TGPSolidBrush.Create($80FF0000);   Graphics.ScaleTransform(27.3, 17.3);   for i := 0 to 4 do   begin     Graphics.PixelOffsetMode := TGPPixelOffsetMode(i);     Graphics.FillRectangle(Brush, Rect);     Rect.Offset(0, Rect.Height + 1);   end;end;

另外在补充一个万一老师的GDI+的学习文章列表地址,虽然是用Delphi写的,但是还是有参考意义:

转载于:https://www.cnblogs.com/xiashengwang/p/4224074.html

你可能感兴趣的文章
大数据:安全分析产品的发展重点
查看>>
微软认知服务为企业带来云AI
查看>>
关于linux下的mysql配置流程以及项目发布的流程
查看>>
汇总站外seo方法和做法?
查看>>
选择使用正确的 Markdown Parser
查看>>
SaaS的中国式成功 中企开源服务保障体系揭秘
查看>>
大数据资源争夺战此起彼伏 对用户而言是福是祸?
查看>>
Java 高效压缩zip
查看>>
什么是自行车码表?自行车码表工作原理?自行车码表安装设置?
查看>>
《MATLAB/Simulink系统仿真超级学习手册》——导读
查看>>
微软准备开源 PowerShell!
查看>>
AMD 向 LibreOffice 贡献 GPU 代码 电子表格速度提升500倍
查看>>
J-SUtil-1.1.3_3 支持对象关联映射查询
查看>>
Opera 32 桌面版发布,新增动态背景功能
查看>>
《精解Windows8》——2.4 关闭计算机
查看>>
《嵌入式 Linux C 语言应用程序设计(修订版)》——2.4 嵌入式Linux调试器GDB的使用...
查看>>
【秒懂设计模式】建造者模式
查看>>
在 Ionic 框架移动应用中支持 iBeacons
查看>>
《Hadoop集群与安全》一第2章 安装和配置Hadoop
查看>>
从ConcurrentHashMap的演进看Java多线程核心技术
查看>>