//显示并保存图片 JPG
procedure TMenuForm.FootImageClick(Sender: TObject);
var
tempStream:TMemoryStream;
JpgPic:TJpegImage;
S:String;
begin
if FootImage.Picture.Width=0 then
begin
if OpenDialog.Execute then
begin
S:=OpenDialog.FileName;
S:=UpperCase(Copy(S,Length(S)-2,3));
if S='JPG' then
begin
try
JpgPic:=TJpegImage.Create;
tempStream:=TMemoryStream.Create;
tempStream.Clear;
a.Dataset.Edit;
JpgPic.LoadFromFile(OpenDialog.FileName);
FootImage.Picture.bitmap.assign(JpgPic);
JpgPic.SaveToStream(tempStream);
TBlobField(a.Dataset.FieldByName('图象')).LoadFromStream(tempStream) ;
a.Dataset.Post;
finally
JpgPic.Free;
tempStream.Free;
end;
end;
end;
end;
end;
//读取并显示图片 JPG
procedure TMenuForm.ShowImage;
var
MyJpeg:TJpegImage;
MyStm:TMemoryStream;
begin
a.GetSelRow;
if not a.DataSet.FieldByName('图象').IsNull then
begin
try
MyJpeg:=TJpegImage.Create;
MyStm:=TMemoryStream.Create;
MyStm.Clear;
TBlobField(a.Dataset.FieldByName('图象')).SaveToStream(MyStm);
MyStm.Position:=0;
MyJpeg.LoadFromStream(MyStm);
FootImage.Picture.BitMap.Assign(MyJpeg);
finally
MyJpeg.Free;
MyStm.Free;
end;
end
else
begin
if FootImage.Picture<>Nil then
begin
FootImage.Picture.Assign(Nil);
end;
end;
end;