方法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
if not OpenPictureDialog1.Execute then exit;
for i := 0 to OpenPictureDialog1.Files.Count - 1 do
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;