IGDI+是一个免费开源封装微软GDI+功能的Delphi库,该库使得可以用Delphi语言代码快速简短的实现复杂GDI+应用程序。
官方网站:http://www.mitov.com/html/igdi_.html
SourceForge:https://sourceforge.net/projects/igdiplus/
安装方法:
1.首先下载目前最新版的IGDI+,解压到任意目录下,这里我解压到D盘;
2.打开Delphi 7→Tools→Environment Options→Library→Library path,然后点击右边的“...”,添加IGDI+的目录路径,确定完成,如下图所示:
如要在程序中使用IGDI+的话
1.首先在单元头uses内包含IGDIPlus,如:uses IGDIPlus;
2.在窗体的OnPaint事件中,添加如下测试代码:
procedure TForm1.FormPaint(Sender: TObject);
var
AGraphics: IGPGraphics;
APen: IGPPen;
AFont: IGPFont;
ABrush: IGPSolidBrush;
rc: TPoint;
begin
AGraphics := TGPGraphics.Create(Canvas);
AGraphics.SmoothingMode := SmoothingModeAntiAlias; //指定平滑(抗锯齿)
AGraphics.TextRenderingHint := TextRenderingHintAntiAlias; //指定使用过程中呈现的文本采用反走样
APen := TGPPen.Create( $FF000000, 3);
AGraphics.DrawLine(APen, 5, 5, 100, 100);
APen.Color := $FF0000FF;
APen.Width := 2;
AGraphics.DrawEllipse(APen, 120, 5, 100, 100);
Canvas.Font. Name := '微软雅黑';
Canvas.Font.Size := 13;
AFont := TGPFont.Create(Canvas.Handle);
ABrush := TGPSolidBrush.Create( $FFFF0000);
rc.X := 10;
rc.Y := 150;
AGraphics.DrawString( '无幻博客'+# 13# 10+ 'http://blog.csdn.net/akof1314',AFont,rc,ABrush);
end;
var
AGraphics: IGPGraphics;
APen: IGPPen;
AFont: IGPFont;
ABrush: IGPSolidBrush;
rc: TPoint;
begin
AGraphics := TGPGraphics.Create(Canvas);
AGraphics.SmoothingMode := SmoothingModeAntiAlias; //指定平滑(抗锯齿)
AGraphics.TextRenderingHint := TextRenderingHintAntiAlias; //指定使用过程中呈现的文本采用反走样
APen := TGPPen.Create( $FF000000, 3);
AGraphics.DrawLine(APen, 5, 5, 100, 100);
APen.Color := $FF0000FF;
APen.Width := 2;
AGraphics.DrawEllipse(APen, 120, 5, 100, 100);
Canvas.Font. Name := '微软雅黑';
Canvas.Font.Size := 13;
AFont := TGPFont.Create(Canvas.Handle);
ABrush := TGPSolidBrush.Create( $FFFF0000);
rc.X := 10;
rc.Y := 150;
AGraphics.DrawString( '无幻博客'+# 13# 10+ 'http://blog.csdn.net/akof1314',AFont,rc,ABrush);
end;
3.运行结果如下图所示:
IGDI+库下载:
地址一:http://www.mitov.com/IGDIPlus.zip
地址二:http://download.csdn.net/source/3039922