Mega Code Archive

 
Categories / Delphi / Graphic
 

How to tile a background image

Title: How to tile a background image? Question: How to tile a background image? Answer: Procedure TileImage(const FileName: TFileName; Sender: TObject); var x, y: Integer; MyBmp: TBitmap; begin MyBmp := TBitmap.Create; try MyBmp.LoadFromFile(FileName); with (Sender as TImage) do begin for x := 0 to (Width div MyBmp.Width) do for y := 0 to (Height div MyBmp.Height) do Canvas.Draw(x * MyBmp.Width, y * MyBmp.Height, bmp); end; finally MyBmp.Free; end; end;