大悟还俗

邮箱 key_ok@qq.com 我的收集 http://pan.baidu.com/share/home?uk=1177427271
posts - 236, comments - 8, trackbacks - 0, articles - 0
  新随笔 :: 联系 :: 订阅 订阅 :: 管理

公告

jpeg

Posted on 2013-12-16 13:45 大悟还俗 阅读(...) 评论(...) 编辑 收藏

方法1:

procedure TForm1.Button2Click(Sender: TObject);
var
  JPEGImage: TJPEGImage;
begin
if SavePictureDialog1.InitialDir =''then
    SavePictureDialog1.InitialDir := ExtractFilePath(OpenPictureDialog1.FileName);
if trim(LabeledEdit1.Text) <>''then
    SavePictureDialog1.FileName := trim(LabeledEdit1.Text) +'.jpg ';
if SavePictureDialog1.execute then
begin
    JPEGImage := TJPEGImage.Create;
    JPEGImage.Assign(image1.Picture.Graphic);
    JPEGImage.CompressionQuality:=25;
    JPEGImage.Compress;
    JPEGImage.SaveToFile(ExtractFilePath(SavePictureDialog1.Filename) + trim(LabeledEdit1.Text) +'.jpg ');
end;
end;

 

方法2:

 

procedure Tf_NewsPic.BitBtn1Click(Sender: TObject);
var
  i: Integer;
  JI: TJPEGImage;
begin
ifnot OpenPictureDialog1.Execute then exit;
for i :=0to OpenPictureDialog1.Files.Count -1do
begin
    JI := TJPEGImage.Create;
    JI.LoadFromFile(OpenPictureDialog1.Files[i]);
    image4.Picture.Bitmap.Assign(JI);
    JI.Assign(image4.Picture.Bitmap);
    JI.CompressionQuality :=25;
    JI.Compress;
    JI.SaveToFile(zhtier.GetTempDir + ExtractFileName(OpenPictureDialog1.Files[i]));
    Q1.Append;
    TBlobField(Q1.Fieldbyname('图片')).LoadFromFile(OpenPictureDialog1.Files[i]);
    Q1.Post;
    JI.Free;
end;
  Q1.Last;
end;