[delphi][GDI+] 学习记录(9): 纹理画刷 – TextureBrush

  • A+
所属分类:[开发技巧]

//纹理画刷
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);
img.Free;
tb.Free;
g.Free;
end;


//Matrix
var
g: TGPGraphics;
img: TGPImage;
tb: TGPTextureBrush;
matrix: TGPMatrix;
begin
g := TGPGraphics.Create(Canvas.Handle);
img := TGPImage.Create('c:\temp\x.jpg');
tb := TGPTextureBrush.Create(img);
matrix := TGPMatrix.Create(75.0/640.0, 0.0, 0.0, 75.0/480.0, 0.0, 0.0);
tb.SetTransform(matrix);
g.FillEllipse(tb, 0, 0, Self.ClientWidth, Self.ClientHeight);
matrix.Free;
img.Free;
tb.Free;
g.Free;
end;

//WrapMode
var
g : TGPGraphics;
img: TGPImage;
tb : TGPTextureBrush;
p: TGPPen;
begin
g := TGPGraphics.Create(Canvas.Handle);
img := TGPImage.Create('c:\temp\small.jpg');
tb := TGPTextureBrush.Create(img);
p := TGPPen.Create(MakeColor(255, 0, 0, 0));
tb.SetWrapMode(WrapModeTile);
g.FillRectangle(tb, MakeRect(0, 0, 200, 200));
g.DrawRectangle(p, MakeRect(0, 0, 200, 200));
tb.SetWrapMode(WrapModeTileFlipX);
g.FillRectangle(tb, MakeRect(200, 0, 200, 200));
g.DrawRectangle(p, MakeRect(200, 0, 200, 200));
tb.SetWrapMode(WrapModeTileFlipY);
g.FillRectangle(tb, MakeRect(0, 200, 200, 200));
g.DrawRectangle(p, MakeRect(0, 200, 200, 200));
tb.SetWrapMode(WrapModeTileFlipXY);
g.FillRectangle(tb, MakeRect(200, 200, 200, 200));
g.DrawRectangle(p, MakeRect(200, 200, 200, 200));
img.Free;
tb.Free;
p.Free;
g.Free;
end;

WrapMode 选项:

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
广告也精彩
avatar
广告也精彩

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: