procedure TFootForm.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;
DataForm.cp1.Edit;
JpgPic.LoadFromFile(OpenDialog.FileName);
FootImage.Picture.bitmap.assign(JpgPic);
JpgPic.SaveToStream(tempStream);
TBlobField(DataForm.cp1.FieldByName('图象')).LoadFromStream(tempStream) ;
DataForm.cp1.Post;
finally
JpgPic.Free;
tempStream.Free;
end;
end;
end;
end;
end;
procedure TFootForm.FormShow(Sender: TObject); //显示图象
var
MyJpeg:TJpegImage;
MyStm:TMemoryStream;
begin
ShowFootInfo;
if not DataForm.cp1.FieldByName('图象').IsNull then
begin
try
MyJpeg:=TJpegImage.Create;
MyStm:=TMemoryStream.Create;
MyStm.Clear;
TBlobField(DataForm.cp1.FieldByName('图象')).SaveToStream(MyStm);
MyStm.Position:=0;
MyJpeg.LoadFromStream(MyStm);
FootImage.Picture.BitMap.Assign(MyJpeg);
finally
MyJpeg.Free;
MyStm.Free;
end;
end;
end;