GdiPlus[8]: IGPTextureBrush 之 WrapMode 属性


示例图片:

o_09121302.png

示例代码:

uses GdiPlus;

procedure TForm1.FormPaint(Sender: TObject);
var
  Graphics: IGPGraphics;
  Image: IGPImage;
  Brush: IGPTextureBrush;
  Rect: TGPRect;
begin
  ChDir('C:\GdiPlusImg\');
  Image := TGPImage.Create('HouseAndTree.gif');
  Brush := TGPTextureBrush.Create(Image);
  Graphics := TGPGraphics.Create(Handle);
  Rect.Initialize(Image.Width, Image.Height, Image.Width * 2, Image.Height * 2);

  Graphics.Clear($FFFFFFFF);
  Graphics.DrawImage(Image, 0, 0, Image.Width, Image.Height);

  //Brush.WrapMode := WrapModeTile; //默认
  Graphics.FillRectangle(Brush, Rect);

  Brush.WrapMode := WrapModeTileFlipX;
  Graphics.TranslateTransform(0, Rect.Y + Rect.Height);
  Graphics.FillRectangle(Brush, Rect);

  Brush.WrapMode := WrapModeTileFlipY;
  Graphics.TranslateTransform(Rect.X + Rect.Width, -Graphics.Transform.OffsetY);
  Graphics.FillRectangle(Brush, Rect);

  Brush.WrapMode := WrapModeTileFlipXY;
  Graphics.TranslateTransform(0, Rect.Y + Rect.Height);
  Graphics.FillRectangle(Brush, Rect);
end;
展开阅读全文

没有更多推荐了,返回首页