Subject Re: [IBO] Graphics from BLOB column
Author Maik Wojcieszak
Hi,

I think something like this will do it


function LoadImageFile(id: Integer) : TBitmap;
var
DatStream : TStream;
Stream : TMemoryStream;
qry : TIB_Query;
bmp : TBitmap;
begin
qry := TIB_Query.Create(Self);
//-- init qry with connection and transaction


qry.SQL.Add('select HIGH_RES_DATA from IMAGE_TAB');
qry.SQL.Add('where IMAGE_ID = :id');

qry.ParamByName('id').AsInteger := id;

qry.Prepare;
qry.Open;
qry.First;

if qry.FieldByName('HIGH_RES_DATA').AsVariant = NULL then begin
MessageDlg(NO_DATA_RS,mtError,[mbOk],0);
end else begin
DatStream :=
qry.CreateBlobStream(qry.FieldByName('HIGH_RES_DATA'), bsmRead);

// load image from Stream
Stream := TMemoryStream.Create;
try
bmp := TBitmap.Create;
Stream.LoadFromStream(DatStream);
bmp.LoadFromStream(Stream);
except
bmp.Destroy;
bmp := nil;
MessageDlg(CANNOT_LOAD_DATA_RS , mtError,[mbOk],0);
end;

DatStream.Free;
Stream.Free;
//ToolButton2Click(Self);
end;

// abfrage schließen
qry.Close;
qry.Unprepare;
qry.Destroy;
result := bmp;
end;


On Wed, 03 Jul 2002 12:11:20 +0400, vsokolov65@... wrote:

>Hello,
>
>How can I get a bitmap from blob field in the TIB_Query and use it as TBitmap
>object?
>
>Thanks,
>Vladimir
>
>
>___________________________________________________________________________
>IB Objects - direct, complete, custom connectivity to Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
>___________________________________________________________________________
>http://www.ibobjects.com - your IBO community resource for Tech Info papers,
>keyword-searchable FAQ, community code contributions and more !
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


-------------------------------------------------
Maik Wojcieszak

wobe-team (http://www.wobe-team.com)