2,496
社区成员
发帖
与我相关
我的任务
分享
试一下这样
var
jpg : TJpegImage;
ImgFile : string;
srm:TStringStream;
blob:TStream;
begin
ImgFile := ExtractFilePath(Application.ExeName)+'\Photo\'
+ eJGRYF.Qry1.FieldByName('gongwy_id').AsString +'.jpg';
try
srm:=TStringStream.create('');
with eJGRYF.Qry1 do
begin
Close;
SQL.Clear;
SQL.Text:='Select * From gongwy_photo Where ( GONGWY_ID = '''
+ DM.GWYQ.FieldByName('GONGWY_ID').AsString + ''')' ;
Open;
First;
blob:=eJGRYF.Qry1.CreateBlobStream(FieldByName('GONGWY_PHOTO_FILE'),bmRead);
blob.Seek(0,soFromBeginning);
Showmessage(inttostr(blob.Size));
//TBlobField(FieldByName('GONGWY_PHOTO_FILE')).SaveToStream(srm);//这里还是显示“Invalid Class Typecast”的错误
//srm.position:=0;
//eJGRYF.img1.picture.graphic.loadfromstream(srm);
end;
finally
srm.free;
eJGRYF.img1.picture.SaveToFile(ImgFile);
end;
end;
procedure ShowPhoto;
var
jpg : TJpegImage;
ImgFile : string;
srm:TStringStream;
begin
ImgFile := ExtractFilePath(Application.ExeName)+'\Photo\'
+ eJGRYF.Qry1.FieldByName('gongwy_id').AsString +'.jpg';
try
srm:=TStringStream.create('');
with eJGRYF.Qry1 do
begin
Close;
SQL.Clear;
SQL.Text:='Select * From gongwy_photo Where ( GONGWY_ID = '''
+ DM.GWYQ.FieldByName('GONGWY_ID').AsString + ''')' ;
Open;
First;
TBlobField(FieldByName('GONGWY_PHOTO_FILE')).SaveToStream(srm);//这里还是显示“Invalid Class Typecast”的错误
srm.position:=0;
eJGRYF.img1.picture.graphic.loadfromstream(srm);
end;
finally
srm.free;
eJGRYF.img1.picture.SaveToFile(ImgFile);
end;