示例圖片:
示例代碼:
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;