示例图片:



示例代码:

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;

posted on 2009-12-13 22:05  万一  阅读(2604)  评论(0编辑  收藏  举报