X und Y werden relativ zur Paintbox gesehn, also benötigt man hier kein Offset.
Delphi-Quellcode:
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
img: TJPEGImage;
I: Integer;
begin
img := TJPEGImage.Create;
try
img.LoadFromFile('back.jpg');
for I := 0 to PaintBox1.Width div img.Width - 1 do
PaintBox1.Canvas.Draw(img.Width * I, 0, img);
finally
img.Free;
end;
end;
aber Besser wäre es so
Delphi-Quellcode:
procedure TForm1.Form1Create(Sender: TObject);
begin
img := TJPEGImage.Create;
img.LoadFromFile('back.jpg');
end;
procedure TForm1.Form1Destroy(Sender: TObject);
begin
img.Free;
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
I: Integer;
begin
for I := 0 to PaintBox1.Width div img.Width - 1 do
PaintBox1.Canvas.Draw(img.Width * I, 0, img);
end;