随笔 - 2146  文章 - 97 评论 - 11765 trackbacks - 253


示例图片:



示例代码:

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 万一 阅读(...) 评论(...) 编辑 收藏