delphi实现.bmp位图旋转90度。求!该怎么处理

delphi实现.bmp位图旋转90度。急求!!!
小白求助大神们,请问怎么在delphi中实现位图的旋转啊,比如说打开一幅.bmp的图片(用系统自带的画图工具就行),然后旋转90度(顺时针逆时针都行),然后保存并输出来。
比如说就像这样,点击图像按钮显示原图,点击旋转按钮后图像旋转并在上面显示delphi实现.bmp位图旋转90度。求!该怎么处理
------解决思路----------------------
顺时针90度
procedure TSeleteImageFrm.Button4Click(Sender: TObject);
var i,j:integer;
    k,all:Longint;
    im:Tbitmap;
begin
  GaugeFrm.show;
  GaugeFrm.Caption:='处理数据......';
  GaugeFrm.Gauge1.Progress:=0;
  im:=Tbitmap.Create;
  im.Assign(jpbmp(Tjpegimage(image1.Picture.Graphic)));
//确定旋转后位图的大小
  image1.Picture.Bitmap.Height:=im.Width;
  image1.Picture.Bitmap.Width:=im.Height;
  image2.Picture.Bitmap.Height:=im.Width;
  image2.Picture.Bitmap.Width:=im.Height;
  image1.Picture.CleanupInstance;  //清除图象
  image2.Picture.CleanupInstance;  //清除图象
  K:=0;
  all:=Trunc(im.Height*im.Width);
  for i:=0 to im.Height do
    for j:=0 to im.Width do
    begin
      K:=K+1;
      GaugeFrm.Gauge1.Progress:=Trunc(100*K/all);
      image1.Canvas.Pixels[(-i+im.Height),j]:=im.Canvas.Pixels[j,i];
      image2.Canvas.Pixels[(-i+im.Height),j]:=im.Canvas.Pixels[j,i];
    end;
  im.Free;
  ChangeImageSize;
  GaugeFrm.close;
end;

反时针90度
procedure TSeleteImageFrm.Button6Click(Sender: TObject);
var i,j:integer;
    k,all:Longint;
    im:Tbitmap;
begin
  GaugeFrm.show;
  GaugeFrm.Caption:='处理数据......';
  GaugeFrm.Gauge1.Progress:=0;
  im:=Tbitmap.Create;
  im.Assign(jpbmp(Tjpegimage(image1.Picture.Graphic)));
//确定旋转后位图的大小
  image1.Picture.Bitmap.Height:=im.Width;
  image1.Picture.Bitmap.Width:=im.Height;
  image2.Picture.Bitmap.Height:=im.Width;
  image2.Picture.Bitmap.Width:=im.Height;
  image1.Picture.CleanupInstance;  //清除图象
  image2.Picture.CleanupInstance;  //清除图象
  K:=0;
  all:=Trunc(im.Height*im.Width);
  for i:=0 to im.Height do
    for j:=0 to im.Width do
    begin
      K:=K+1;
      GaugeFrm.Gauge1.Progress:=Trunc(100*K/all);
      image1.Canvas.Pixels[i,(-j+im.Width)]:=im.Canvas.Pixels[j,i];
      image2.Canvas.Pixels[i,(-J+im.Width)]:=im.Canvas.Pixels[j,i];
    end;
  im.Free;
  ChangeImageSize;
  GaugeFrm.close;
end;

------解决思路----------------------
翻转(水平)
procedure TSeleteImageFrm.Button13Click(Sender: TObject);
var i,j:integer;
    k,all:Longint;
    im:Tbitmap;
begin
  GaugeFrm.show;
  GaugeFrm.Caption:='处理数据......';
  GaugeFrm.Gauge1.Progress:=0;
  im:=Tbitmap.Create;
  im.Assign(jpbmp(Tjpegimage(image1.Picture.Graphic)));
//确定旋转后位图的大小
  image1.Picture.Bitmap.Height:=im.Height;
  image1.Picture.Bitmap.Width:=im.Width;
  image2.Picture.Bitmap.Height:=im.Height;
  image2.Picture.Bitmap.Width:=im.Width;
  image1.Picture.CleanupInstance;  //清除图象
  image2.Picture.CleanupInstance;  //清除图象
  K:=0;
  all:=Trunc(im.Height*im.Width);
  for i:=0 to im.Height do
    for j:=0 to im.Width do
    begin
      K:=K+1;
      GaugeFrm.Gauge1.Progress:=Trunc(100*K/all);
      image1.Canvas.Pixels[(-j+im.Width),(i)]:=im.Canvas.Pixels[j,i];
      image2.Canvas.Pixels[(-J+im.Width),(i)]:=im.Canvas.Pixels[j,i];
    end;
  im.Free;
  ChangeImageSize;
  GaugeFrm.close;
end;

有此代码是显示进度条的,可以删除。使用二个image,目的是显示选择框,你可以只用一个。