插入图像:
if OpenPDia.Execute then
begin
GoodsT.Edit;
(GoodsT.FieldByName('Photo') as TBlobField).loadfromfile(openPdia.filename);
end;
读出jpg,bmp到image中:
procedure TMainFrm.ReadPhotoActExecute(Sender: TObject);
var
JP: TJPEGImage;
bs: TBlobStream;
bmp: Tbitmap;
begin
if not (Table1.IsEmpty) then
begin
bs := TBlobStream.Create((Table1.FieldByName('photo') as TBlobField), bmRead);
try
jp := TJPEGImage.Create;
jp.LoadFromStream(bs);
Image1.Picture.Assign(jp);
bs.free;
jp.free;
except
bs.Free;
jp.Free;
bs := TBlobStream.Create((Table1.FieldByName('photo') as TBlobField), bmRead);
bmp := Tbitmap.Create;
bmp.loadFromStream(bs);
image1.Picture.Assign(bmp);
bs.free;
end;
end;
end;
查查以前的问题,也有很多!