procedure Savemap(cd:TClientDataSet;Bfpic: TBlobField;op: TOpenDialog;Img: TImage;DBImg: TDBImage);
var
picstream:TClientBlobStream;
ghy:TClientBlobStream;
pic:tjpegimage;
begin
if not (CD.State in [dsedit,dsInsert]) then
CD.edit;
picstream:=TClientBlobStream.Create(Bfpic,bmWrite);
try
if Op.execute then
begin
if not FileExists(Op.FileName) then
begin
Application.MessageBox('文件不存在。','提示',MB_ICONERROR);
exit;
end;
picstream.LoadFromFile(Op.filename);
picstream.Seek(0,soFrombegin
ning);
TBlobField(Bfpic).loadfromstream(picstream);
CD.post;
//CDSC.ApplyUpdates(-1);
ghy := TClientBlobStream.Create(Bfpic, bmRead);
try
ghy.Seek(JpegStartsInBlob1(Bfpic),soFrombegin
ning);
Pic:=TJpegImage.Create;
try
Pic.LoadFromStream(ghy);
DBImg.Picture.Graphic:=Pic;
finally
Pic.Free;
end;
finally
ghy.Free
end;
img.Picture := DBImg.Picture;
DBImg.Width := img.Width;
DBImg.Height := img.Height;
Img.Visible:=true;
end;
finally
picstream.Free;
end;
end;