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

//纹理画刷
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 选项:

Delphi 微软 说明
WrapModeClamp Clamp 纹理或渐变没有平铺。
WrapModeTile Tile 平铺渐变或纹理。
WrapModeTileFlipX TileFlipX 水平反转纹理或渐变,然后平铺该纹理或渐变。
WrapModeTileFlipXY  TileFlipXY  水平和垂直反转纹理或渐变,然后平铺该纹理或渐变。
WrapModeTileFlipY TileFlipY 垂直反转纹理或渐变,然后平铺该纹理或渐变。


你可能感兴趣的:(GDI+ 学习记录(9): 纹理画刷 - TextureBrush)