Subject Re: [firebird-support] BLOB Problem - NO TDBImage
Author Dimitry Sibiryakov
On 9 Aug 2003 at 15:17, H.I.S Developer wrote:

> I am not using any DB component.

You are using TQuery at least.

>I use something like
>For Storing
>q.FieldByName('DOCMANIMAGE').LoadFromFile('c:/temp.bmp')

Graphic type is recognized by file's extension.

>q.FieldByName('DOCMANIMAGE').Assign(Image1.Picture.Graphic)//where
>image 1 has the image of c:/temp.bmp

Graphic type is recognized by Picture.Graphic type.

>For Retriving
>q.FieldByName('TESTIMAGE').SaveToFile('c:/temp.bmp')

Graphic type is recognized by a little header. Unfortunatelly, VCL
code can handle very few types of graphic.

>I get the error the moment the query is opened

Look at the code in TBlobField.AssignTo() and you'll get all
answers.
Look at my code for saving image to BLOB (FIB+). Note a little
header that is added in front of message data.

bs := TFIBBlobStream.Create;
try
bs.Mode := bmWrite;
bs.DataBase := Tables.MarketServer;
bs.Transaction := EditTransaction;
bs.Write(GraphicHeader,SizeOf(GraphicHeader));
Logo.SaveToStream(bs);
GraphicHeader.Count := 1;
If Logo is TBitmap then
GraphicHeader.HType := $0100
else
If Logo is TMetafile then
GraphicHeader.HType := $0200
else
If Logo is TIcon then
GraphicHeader.HType := $0300
else
If Logo is TGIFImage then
GraphicHeader.HType := $0400
else
If Logo is TJPEGImage then
GraphicHeader.HType := $0500
else
GraphicHeader.HType := 0;
GraphicHeader.Size := bs.Size-SizeOf(GraphicHeader);
bs.Seek(0,soFromBeginning);
bs.Write(GraphicHeader,SizeOf(GraphicHeader));
bs.Finalize;
LogoID := bs.BlobID;


SY, Dimitry Sibiryakov.