问题来源: http://www.cnblogs.com/del/archive/2009/01/09/1373051.html#1743248
procedure TForm1.Button1Click(Sender: TObject);
var
Bits: array[0..5] of TBitmap; { 假定有 6 张相同大小的图片需要拼合 }
i,n,x,y: Integer; { n 用作列数; x,y 用作位置}
begin
n := 3; { 假如每行排 3 张; 可随意修改}
{ 读取图片, 假如图片是放在 C:\Temp\ 下, 并命名为 1.bmg、2.bmp ... 6.bmp }
ChDir('C:\Temp\');
for i := 0 to Length(Bits) - 1 do
begin
Bits[i] := TBitmap.Create;
Bits[i].LoadFromFile(IntToStr(i+1) + '.bmp');
end;
{ 设置 Image1 的大小}
if (n > Length(Bits)) or (n <= 0) then n := Length(Bits);
Image1.Width := Bits[Low(Bits)].Width * n;
Image1.Height := Bits[Low(Bits)].Height * (Length(Bits) div n);
if Length(Bits) mod n > 0 then
Image1.Height := Image1.Height + Bits[Low(Bits)].Height;
{ 绘制 }
x := 0;
y := 0;
for i := 0 to Length(Bits) - 1 do
begin
Image1.Canvas.Draw(x, y, Bits[i]);
Inc(x, Bits[i].Width);
if x >= Image1.Width then
begin
x := 0;
Inc(y, Bits[i].Height);
end;
Bits[i].Free;
end;
end;