//方法
IGPGraphics.DrawLine(); { 畫線 }
IGPGraphics.DrawLines(); { 畫一組線 }
IGPGraphics.DrawArc(); { 畫弧線 }
IGPGraphics.DrawBezier(); { 畫 BezIEr 線 }
IGPGraphics.DrawBeziers(); { 畫一組 BezIEr 線 }
IGPGraphics.DrawRectangle(); { 畫矩形 }
IGPGraphics.DrawRectangles(); { 畫一組矩形 }
IGPGraphics.DrawEllipse(); { 畫橢圓 }
IGPGraphics.DrawPIE(); { 畫餅形 }
IGPGraphics.DrawPolygon(); { 畫多邊形 }
IGPGraphics.DrawCurve(); { 畫曲線 }
IGPGraphics.DrawClosedCurve(); { 畫閉合曲線 }
IGPGraphics.DrawPath(); { 畫路徑 }
IGPGraphics.FillRectangle(); { 填充矩形 }
IGPGraphics.FillRectangles(); { 填充一組矩形 }
IGPGraphics.FillPolygon(); { 填充多邊形 }
IGPGraphics.FillEllipse(); { 填充橢圓 }
IGPGraphics.FillPIE(); { 填充餅形 }
IGPGraphics.FillPath(); { 填充路徑 }
IGPGraphics.FillClosedCurve(); { 填充閉合曲線 }
IGPGraphics.FillRegion(); { 填充區域 }
IGPGraphics.DrawImage(); { 呈現圖像 }
IGPGraphics.DrawCachedBitmap(); { 呈現 CachedBitmap 圖像 }
IGPGraphics.AddMetafileComment(); { 向當前 Metafile 添加注釋 }
IGPGraphics.EnumerateMetafile(); { 枚舉 Metafile 中的圖形命令 }
IGPGraphics.DrawString(); { 繪制文本 }
IGPGraphics.MeasureString(); { 獲取指定格式的字符串需要的矩形 }
IGPGraphics.DrawDriverString(); { 繪制可指定間距的文本 }
IGPGraphics.MeasureDriverString(); { 獲取可指定間距文本所需要的矩形范圍 }
IGPGraphics.MeasureCharacterRanges(); { 獲取指定字符所在的區域 }
IGPGraphics.SetClip(); { 設置 Graphics 的繪圖區域 }
IGPGraphics.IntersectClip(); { 通過相交運算設置新的剪切區域 }
IGPGraphics.ExcludeClip(); { 減去剪切區域 }
IGPGraphics.ResetClip; { 重置剪切區域 }
IGPGraphics.TranslateClip(); { 平移剪切區域 }
IGPGraphics.IsVisible(); { 判斷指定的點或矩形是否包含在 Graphics 可見剪切區域內 }
IGPGraphics.Clear(); { 清除繪圖表面並以指定背景色填充 }
IGPGraphics.Save; { 保存 Graphics 當前狀態 }
IGPGraphics.Restore(); { 恢復由 Save 保存的狀態 }
IGPGraphics.Flush(); { 強制執行所有掛起的圖形操作並立即返回而不等待操作完成 }
IGPGraphics.GetNearestColor(); { 獲取與指定顏色參數最接近的系統顏色 }
IGPGraphics.GetHDC; { 獲取 Graphics 關聯的 HDC }
IGPGraphics.ReleaseHDC(); { 釋放 Graphics 關聯的 HDC }
IGPGraphics.GetRenderingOrigin(); { 獲取原點 }
IGPGraphics.SetRenderingOrigin(); { 設置原點 }
IGPGraphics.MultiplyTransform(); { 將 Graphics 的世界變換乘以指定的 Matrix }
IGPGraphics.TranslateTransform(); { 平移變換 }
IGPGraphics.ScaleTransform(); { 放縮變換 }
IGPGraphics.RotateTransform(); { 旋轉變換 }
IGPGraphics.ResetTransform; { 重置變換 }
IGPGraphics.BeginContainer(); { 保存之前的狀態, 並開始一個新的狀態 }
IGPGraphics.EndContainer(); { 還原由 BeginContainer 保存的狀態 }
IGPGraphics.TransformPoints(); { 將點數組轉換坐標空間 }
//屬性
IGPGraphics.DpiX; { 獲取 Graphics 水平分辨率 }
IGPGraphics.DpiY; { 獲取 Graphics 垂直分辨率 }
IGPGraphics.RenderingOrigin; { 原點 }
IGPGraphics.PageScale; { 獲取或設置 Graphics 的全局單位和頁單位之間的比例 }
IGPGraphics.PageUnit; { 獲取或設置 Graphics 中頁坐標的度量單位 }
IGPGraphics.Transform; { 獲取或設置矩陣變換 }
IGPGraphics.CompositingMode; { 前景色與背景色的合成混合模式 }
IGPGraphics.InterpolationMode; { 插補模式 }
IGPGraphics.PixelOffsetMode; { 像素的偏移模式 }
IGPGraphics.CompositingQuality; { 圖像合成質量 }
IGPGraphics.SmoothingMode; { 繪圖質量 }
IGPGraphics.TextRenderingHint; { 獲取或設置文本呈現模式 }
IGPGraphics.TextContrast; { 獲取或設置文本灰度校正值(消除鋸齒和 ClearType 文本的伽瑪值校正: 0..12, 默認4) }
IGPGraphics.Clip; { 獲取或設置 Graphics 的繪圖區域 }
IGPGraphics.ClipBounds; { 獲取剪切區域的矩形邊界; 浮點型 }
IGPGraphics.ClipBoundsI; { 獲取剪切區域的矩形邊界; 整型 }
IGPGraphics.VisibleClipBounds; { 可見的剪切區域的矩形邊界; 浮點型 }
IGPGraphics.VisibleClipBoundsI; { 可見的剪切區域的矩形邊界; 整型 }
IGPGraphics.IsClipEmpty; { 剪切區域是否為空 }
IGPGraphics.IsVisibleClipEmpty; { 可見的剪切區域是否為空 }
關於剪切區域的例子:
uses GdiPlus;
var
Graphics: IGPGraphics;
Image: IGPImage;
procedure TForm1.FormCreate(Sender: TObject);
var
Rect1, Rect2: TGPRect;
Path1, Path2: IGPGraphicsPath;
begin
Image := TGPImage.Create('C:\GdiPlusImg\ImageFileSmall.jpg');
Graphics := TGPGraphics.Create(Handle);
Rect1.Initialize(20, 20, 120, 120);
Rect2.Initialize(120, 20, 120, 120);
Path1 := TGPGraphicsPath.Create;
Path2 := TGPGraphicsPath.Create;
Path1.AddEllipse(Rect1);
Path2.AddEllipse(Rect2);
Graphics.SetClip(Path1);
Graphics.SetClip(Path2, CombineModeUnion);
end;
procedure TForm1.FormPaint(Sender: TObject);
begin
if not Graphics.IsVisibleClipEmpty then
begin
Graphics.SetClip(Graphics.VisibleClipBoundsI, CombineModeIntersect);
Graphics.DrawImage(Image, 10, 10);
end;
end;
PageUnit、PageScale 測試:
uses GdiPlus;
procedure TForm1.FormPaint(Sender: TObject);
var
Graphics: IGPGraphics;
Pen: IGPPen;
Rect: TGPRect;
begin
Graphics := TGPGraphics.Create(Handle);
Rect.Initialize(20, 20, 200, 150);
Pen := TGPPen.Create($FFC0C0C0, 3);
Graphics.DrawRectangle(Pen, Rect);
Graphics.PageUnit := UnitDocument; { PageScale 只在頁面坐標下有效 }
Graphics.PageScale := 1.0; //默認
Pen.Color := $FF0000FF;
Graphics.DrawRectangle(Pen, Rect);
Pen.Color := $FFFF0000;
Graphics.PageScale := 2.0;
Graphics.DrawRectangle(Pen, Rect);
end;
BeginContainer、EndContainer 前者是開始變換, 後者是重置到變換之前的狀態:
uses GdiPlus;
procedure TForm1.FormPaint(Sender: TObject);
var
Graphics: IGPGraphics;
Pen: IGPPen;
Rect: TGPRect;
begin
Graphics := TGPGraphics.Create(Handle);
Rect.Initialize(60, 60, 100, 100);
Pen := TGPPen.Create($FFC0C0C0, 2);
Graphics.DrawRectangle(Pen, Rect);
Pen.Color := $FF0000FF;
Tag := Graphics.BeginContainer;
Graphics.RotateTransform(18);
Graphics.DrawRectangle(Pen, Rect);
Graphics.EndContainer(Tag);
Pen.Color := $FFFF0000;
Tag := Graphics.BeginContainer;
Graphics.RotateTransform(-18);
Graphics.DrawRectangle(Pen, Rect);
Graphics.EndContainer(Tag);
end;
//用 Save 和 Restore 重復實現的代碼:
uses GdiPlus;
procedure TForm1.FormPaint(Sender: TObject);
var
Graphics: IGPGraphics;
Pen: IGPPen;
Rect: TGPRect;
begin
Graphics := TGPGraphics.Create(Handle);
Rect.Initialize(60, 60, 100, 100);
Pen := TGPPen.Create($FFC0C0C0, 2);
Graphics.DrawRectangle(Pen, Rect);
Pen.Color := $FF0000FF;
Tag := Graphics.Save;
Graphics.RotateTransform(18);
Graphics.DrawRectangle(Pen, Rect);
Graphics.Restore(Tag);
Pen.Color := $FFFF0000;
Graphics.Restore(Tag);
Graphics.RotateTransform(-18);
Graphics.DrawRectangle(Pen, Rect);
Graphics.Restore(Tag);
end;
原點(RenderingOrigin 它變換是兩回事)與陰影畫刷的測試:
uses GdiPlus;
procedure TForm1.FormPaint(Sender: TObject);
var
Graphics: IGPGraphics;
Brush: IGPHatchBrush;
Rect: TGPRect;
begin
Graphics := TGPGraphics.Create(Handle);
Brush := TGPHatchBrush.Create(HatchStyleSolidDiamond, $FF8B0000, $FFFFD700);
Rect.Initialize(10, 10, 108, 60);
Graphics.SetRenderingOrigin(0, 0); //這是默認值
Graphics.FillRectangle(Brush, Rect);
Graphics.TranslateTransform(0, Rect.Y + Rect.Height);
Graphics.SetRenderingOrigin(Rect.X, Rect.Y + Trunc(Graphics.Transform.OffsetY));
Graphics.FillRectangle(Brush, Rect);
end;