2008/05/26 | 裁减图片
类别(语言类学习笔记) | 评论(0) | 阅读(43) | 发表于 13:31
procedure TForm1.Cut(sf:string);
var
  jpg: TJPEGImage;
  Bmp: TBitmap;
begin
  jpg := TJPEGImage.Create;
  Bmp := TBitmap.Create;
  try
    jpg.LoadFromFile(sf);
    self.Image1.Picture.LoadFromFile(sf);
    Bmp.Assign(jpg);
    bmp.Canvas.CopyRect(rect(0,0,jpg.width,jpg.Height),bmp.Canvas,rect(0,0,jpg.Width,jpg.Height-30));
    if SavePictureDialog1.Execute then
    begin
      jpg.SaveToFile(self.SavePictureDialog1.FileName);
      self.Image2.Picture.LoadFromFile(self.SavePictureDialog1.FileName);
    end; 
    //Image2.Canvas.CopyRect(Rect(0,0,Image1.Width,Image1.Height),Bmp.Canvas,Rect(0,0,Image1.Width,Image1.Height-30));
  finally
    jpg.Free;
    Bmp.Free;
  end;
end;
0

评论Comments