Delphi GDI+学习记录(15): 多边形

//多边形描边与填充

var
 g: TGPGraphics;
 p: TGPPen;
 sb: TGPSolidBrush;
 pts: array[0..4] of TGPPoint;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 sb := TGPSolidBrush.Create(MakeColor(255,255,255));
 p := TGPPen.Create(MakeColor(255,0,0),4);
 pts[0].X := 11; pts[0].Y := 11;
 pts[1].X := 66; pts[1].Y := 111;
 pts[2].X := 88; pts[2].Y := 222;
 pts[3].X := 111; pts[3].Y := 88;
 pts[4].X := 222; pts[4].Y := 66;
 g.DrawPolygon(p, PGPPoint(@pts), Length(pts)); {第二个参数是指针类型, 需亚转换}
 g.FillPolygon(sb, PGPPoint(@pts), Length(pts)); {第三个参数是顶点数}
 p.Free;
 sb.Free;
 g.Free;
end;

时间: 2024-12-24 21:20:32

Delphi GDI+学习记录(15): 多边形的相关文章

Delphi GDI+ 学习记录(28): 图像颜色的数据格式

//指定位图颜色var g,gbit: TGPGraphics; bit1,bit2: TGPBitmap; sb: TGPSolidBrush; begin //Self.Color := clWhite; g := TGPGraphics.Create(Canvas.Handle); sb := TGPSolidBrush.Create(MakeColor(255,0,0)); {画刷为红色} bit1 := TGPBitmap.Create(200, 32, PixelFormat32bp

Delphi GDI+学习记录(21): 颜色

//颜色透明度var g: TGPGraphics; sb: TGPSolidBrush; begin g := TGPGraphics.Create(Canvas.Handle); sb := TGPSolidBrush.Create(MakeColor(128,255,0,0)); {128表示半透明} g.FillRectangle(sb,10,10,100,100); sb.Free; g.Free; end; //使用 GDI+ 的颜色类型var g: TGPGraphics; sb:

Delphi GDI+学习记录(3): 虚线画笔

//虚线样式 var g: TGPGraphics; p: TGPPen; begin g := TGPGraphics.Create(Canvas.Handle); p := TGPPen.Create(MakeColor(255,255,0,0),3); g.DrawLine(p, 11, 11, 333, 11); {实线} p.SetDashStyle(DashStyleDashDot); {设置虚线样式} g.DrawLine(p, 11, 33, 333, 33); {绘制任何形状都

Delphi GDI+学习记录(19): 路径

//绘制与填充路径var g: TGPGraphics; path: TGPGraphicsPath; p: TGPPen; sb: TGPSolidBrush; begin g := TGPGraphics.Create(Canvas.Handle); p := TGPPen.Create(MakeColor(128,255,0,0),4); sb := TGPSolidBrush.Create(MakeColor(128,255,255,0)); path := TGPGraphicsPat

Delphi GDI+学习记录(9): 纹理画刷

//纹理画刷 var g: TGPGraphics; img: TGPImage; tb: TGPTextureBrush; begin g := TGPGraphics.Create(Canvas.Handle); img := TGPImage.Create('c:\temp\small.jpg'); tb := TGPTextureBrush.Create(img); g.FillEllipse(tb, 0, 0, Self.ClientWidth, Self.ClientHeight);

Delphi GDI+学习记录(8): 阴影画刷

//阴影画刷 var g: TGPGraphics; hb: TGPHatchBrush; begin g := TGPGraphics.Create(Canvas.Handle); hb := TGPHatchBrush.Create(HatchStyleHorizontal, aclRed, aclYellow); {参数1是阴影样式; 参数2是前景色; 参数3是背景色, 参数3可选, 默认黑色} g.FillEllipse(hb, 11, 11, 222, 111); hb.Free; g

Delphi GDI+学习记录(4): 画笔对齐

//笔对齐 var g: TGPGraphics; p: TGPPen; sb: TGPSolidBrush; rect: TGPRect; begin g := TGPGraphics.Create(Canvas.Handle); p := TGPPen.Create(MakeColor(255,255,0,0),5); sb := TGPSolidBrush.Create(MakeColor(255,255,255,0)); p.SetAlignment(PenAlignmentCenter

Delphi GDI+学习记录(2): 画笔线帽

//线帽 var g: TGPGraphics; p: TGPPen; begin g := TGPGraphics.Create(Canvas.Handle); p:= TGPPen.Create(aclBlue, 8); p.SetStartCap(LineCapArrowAnchor); {起点线帽} p.SetEndCap(LineCapRoundAnchor); {终点线帽} g.DrawLine(p, 20, 20, 300, 175); p.Free; g.Free; end; 线

Delphi GDI+ 学习记录(31): 图像颜色变换(TGPImageAttributes)

//正常显示图片, 没有变换uses GDIPAPI, GDIPOBJ; procedure TForm1.FormPaint(Sender: TObject); var g: TGPGraphics; img: TGPImage; begin g := TGPGraphics.Create(Canvas.Handle); img := TGPImage.Create('c:\temp\test.png'); {测试文件要存在} g.DrawImage(img, 0, 0, img.GetWid