C chen.h Unregistered / Unconfirmed GUEST, unregistred user! 2000-08-15 #1 我是一个初学者,请问各位高手: 在Delphi中如何把数据库中存储的图片保存成一个个的图形文件,给一个例子.(jpg格式) 希望大家给予帮助,谢谢!(尽快)
H honghs Unregistered / Unconfirmed GUEST, unregistred user! 2000-08-16 #4 装入 tblobfield(adoquery1.FieldByName('jpg')).LoadFromFile(FileName) ; 另存为 tblobfield(adoquery1.FieldByName('jpg')).SaveToFile(FileName) ; 显示 procedure Tfrmado.DataSource1DataChange(Sender: TObject; Field: TField); var jpeg:tjpegimage; stream :TMemoryStream; begin if adoquery1jpg.BlobSize>0 then begin jpeg:=tjpegimage.Create; stream :=TMemoryStream.Create; tblobfield(adoquery1.FieldByName('jpg')).savetostream(stream); Stream.Seek(0,soFromBeginning); jpeg.loadfromstream(stream); image.Picture.Bitmap.Assign(jpeg); jpeg.Free; stream.Free; end else image.Picture:=nil; end;
装入 tblobfield(adoquery1.FieldByName('jpg')).LoadFromFile(FileName) ; 另存为 tblobfield(adoquery1.FieldByName('jpg')).SaveToFile(FileName) ; 显示 procedure Tfrmado.DataSource1DataChange(Sender: TObject; Field: TField); var jpeg:tjpegimage; stream :TMemoryStream; begin if adoquery1jpg.BlobSize>0 then begin jpeg:=tjpegimage.Create; stream :=TMemoryStream.Create; tblobfield(adoquery1.FieldByName('jpg')).savetostream(stream); Stream.Seek(0,soFromBeginning); jpeg.loadfromstream(stream); image.Picture.Bitmap.Assign(jpeg); jpeg.Free; stream.Free; end else image.Picture:=nil; end;
C chen.h Unregistered / Unconfirmed GUEST, unregistred user! 2000-08-16 #5 小弟笨拙,不知Tblobfield 和 Ttable 如何联合使用.请指示!
L larryle Unregistered / Unconfirmed GUEST, unregistred user! 2000-08-16 #7 to chen.h, Ttable 有fieldbyname("")函数返回TField class,将之转换成TBLOBField即可。 如有个table1,连接的表中有image字段存放jpg图片 save 用: table1.append; TBLOBField(table1.fieldbyname('image')).loadfromfile('anyimage.jpg'); table1.post; read 用: TBLOBField(table1.fieldbyname('image')).savetofile('anyimage.jpg'); 然后用一Timage空间 iamge1显示。image1.picture.loadfromfile('anyiamge.jpg'); OK. larry
to chen.h, Ttable 有fieldbyname("")函数返回TField class,将之转换成TBLOBField即可。 如有个table1,连接的表中有image字段存放jpg图片 save 用: table1.append; TBLOBField(table1.fieldbyname('image')).loadfromfile('anyimage.jpg'); table1.post; read 用: TBLOBField(table1.fieldbyname('image')).savetofile('anyimage.jpg'); 然后用一Timage空间 iamge1显示。image1.picture.loadfromfile('anyiamge.jpg'); OK. larry