Board index » off-topic » Blob Not Open
Wei Ming, Lee
Delphi Developer |
Blob Not Open2008-03-18 02:55:48 PM off-topic4 Hi, I face problem of retrieve jpeg from TBlobFields and display it over a TImage component. I'm currently using Delphi7.0 and BDE connect to Interbase therefore load and display Jpg content file in interbase. My statement as below: function u1JpegStartsInBlob(PicField:TBlobField):Longint; var bS : TBlobStream; buffer : Word; hx : string; begin Result := -1; bS := TBlobStream.Create(PicField, bmRead); try while (Result = -1) and (bS.Position + 1 < bS.Size) do begin bS.ReadBuffer(buffer, 1); hx:=IntToHex(buffer, 2); if hx = 'FF' then begin bS.ReadBuffer(buffer, 1); hx:=IntToHex(buffer, 2); if hx = 'D8' then Result := bS.Position - 2 else if hx = 'FF' then bS.Position := bS.Position-1; end; //if end; //while finally bS.Free end; //try end; procedure TFmCompInfo.BtnLoadPicClick(Sender: TObject); var B: TStream; Jpg: TJPEGImage; iPos: Longint; bF: TBlobField; begin inherited; with TwwTable(Ds.Dataset) do try // TBlobField(Ds.DataSet.FieldByName('BUEP_COMPIMG')).SaveToStream(B); B:= CreateBlobStream(FieldByName('BUEP_COMPIMG'), bmRead); try iPos:= B.Seek(u1JpegStartsInBlob(TBlobField(FieldByName('BUEP_COMPIMG'))), soFromBeginning); Jpg:= TJPEGImage.Create; if iPos>-1 then begin Jpg.LoadFromStream(B); // <-- msg "Blob not opened" introduce here. Img.Picture.Graphic.Assign(Jpg); end else Img.Picture.Assign(nil); Img.Invalidate; finally B.Free; end; finally Jpg.Free; end; end; Thanks in advance for your help! |