Board index » delphi » Storing JPEG in Blobfield

Storing JPEG in Blobfield

Hi,

I'm trying to store a JPEG-image into an MS Access (97) BlobField using a
TMemoryStream.
When I do so I get an error-message concerning an 'invalid bitmap'. What am
I doing wrong?

   aJPG    := TJPEGImage.create;
   aJPG.loadFromFile(aFile);
   aJPG.compressionQuality := 80;
   aJPG.compress;
   aStream := TMemoryStream.create;
   aJPG.saveToStream(aStream);
   aBlobField.loadFromStream(aStream);   <---error: "invalid bitmap"

thanks for helping me ...

 

Re:Storing JPEG in Blobfield


Try to use the TblobStream to use unsupported bitmap types in a database
you might get a better answer in the B.P.D.DataBase.ADO or
B.P.D.Database.Desktop

Regards
Johnnie.

Quote
Microsoft Student wrote:

> Hi,

> I'm trying to store a JPEG-image into an MS Access (97) BlobField using a
> TMemoryStream.
> When I do so I get an error-message concerning an 'invalid bitmap'. What am
> I doing wrong?

>    aJPG    := TJPEGImage.create;
>    aJPG.loadFromFile(aFile);
>    aJPG.compressionQuality := 80;
>    aJPG.compress;
>    aStream := TMemoryStream.create;
>    aJPG.saveToStream(aStream);
>    aBlobField.loadFromStream(aStream);   <---error: "invalid bitmap"

> thanks for helping me ...

Re:Storing JPEG in Blobfield


Hi,

Microsoft Student schrieb in <90i3t1$r...@bornews.inprise.com>:
^^^^^^^^^^^^^^^^^
 :-)

Quote
> I'm trying to store a JPEG-image into an MS Access (97) BlobField using a
> TMemoryStream.
>    aJPG.saveToStream(aStream);
>    aBlobField.loadFromStream(aStream);   <---error: "invalid bitmap"

You have forgotten rewind.

Insert the line
  aStream.Position := 0;

between the quoted lines.

By Peter.

Other Threads