这段让图片旋转90度的代码执行起来太慢了,请帮帮忙,该怎么处理

这段让图片旋转90度的代码执行起来太慢了,请帮帮忙
请问有无办法优化下,实在太慢了

var
i,j:integer;
begin

image2.Picture.Bitmap.Height:=image1.picture.width;
image2.Picture.Bitmap.Width:=image1.picture.height;
for i:=0 to image1.picture.Height do
for j:=0 to image1.picture.Width do
image2.canvas.Pixels[(-i+image1.picture.Height),j]:=image1.canvas.Pixels[j,i];


------解决方案--------------------
用ScanLine的代码,速度很快:
Delphi(Pascal) code

procedure ImageRF(const Bitmap:TBitmap);
var
i,j:Integer;
rowIn,rowOut:pRGBTriple;
Bmp:TBitmap;
Width,Height:Integer;
begin
Bmp:=TBitmap.Create;
Bmp.Width := Bitmap.Height;
Bmp.Height := Bitmap.Width;
Width:=Bitmap.Width-1;
Height:=Bitmap.Height-1;
if Bitmap.PixelFormat<>pf32Bit then Bitmap.PixelFormat:=pf24Bit;
Bmp.PixelFormat:=Bitmap.PixelFormat;
for j := 0 to Height do
begin
rowIn := Bitmap.ScanLine[j];
for i := 0 to Width do
begin
rowOut := Bmp.ScanLine[i];
Inc(rowOut,Height - j);
rowOut^ := rowIn^;
Inc(rowIn);
end;
end;
Bitmap.Assign(Bmp);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ImageRF(Image1.Picture.Bitmap);
end;