Board index » off-topic » Re: Blob Saving to file

Re: Blob Saving to file


2003-07-03 08:43:34 PM
off-topic9
Joseph,
I think you are using the DBDEMOS database. right?
Actually the BMP stored in the DBDEMOS table is not recognizable by Windows.
I don't know why.
Try reading a standard BMP file into the BLOB field and then Save it to a
different file name. Open this file and you will see the bitmap.
The code:
tblTable.Append;
tblTableBMP.LoadFromFile('c:\some bitmap file.bmp');
tblTable.Post;
tblTableBMP.SaveToFile('c:\another new name.bmp');
HTH,
Sujit
"Joseph Pellicano" <newsgroups.borland.com>wrote in message
Quote
I have an interbase blob field defined as blob sub type 0 segment size 80
which contains a bitmap.

I want to save this bitmap to a file and I am using the following code to
do
it:

var
fs: TFileStream;
bs: TBlobStream;
begin
fs := TFileStream.Create('c:\test.bmp', fmOpenWrite or fmCreate);
bs := TBlobStream.Create(dmMain.dtmMain.tblTableBMP, bmRead);
try
fs.CopyFrom(bs, bs.Size);
finally
bs.Free;
fs.Free;
end;
end;

However when I try to open the file (i.e. c:\test.bmp), I receive an error
that this is not a valid bitmap file or it`s format is not supported.
Can someone tell me where I am wrong and how to save a blob field (may be
of
any type such as jpg, wmf, tif etc) to a file?

Regards

Joseph


 
 

Re:Re: Blob Saving to file

Quote

However when I try to open the file (i.e. c:\test.bmp), I receive an error
that this is not a valid bitmap file or it`s format is not supported.
Can someone tell me where I am wrong and how to save a blob field (may be
of
any type such as jpg, wmf, tif etc) to a file?

Create an (unique?) index if you don't have one.
I had the same problem on a firebird 1.0x database without any index on the
table.
Strange but after I had created an index (in my case unique) the problem was
gone.
HTH
Thomas