Loading Image in MS Access Long Binary Data



Hi I

I have a MS Access table containing a stockcodes and an Images. When
viewing it in MS Access 2003 the picture field displays Long Binary data.

I am trying to load the image into a Timage component with the following
code.

OPtion 1: (JPEG)

procedure TForm1.ADOQuery2AfterScroll(DataSet: TDataSet);
var
MyJpeg : TJpegImage;
BS : TADOBlobStream; //<-- this is defined in ADODB
begin
try
BS := TADOBlobStream.Create(ADOQuery2.FieldByName('picture') as
TBlobField, bmRead );
// SKIP OLE STORAGE HEADER
BS.Seek( 78, soFromBeginning );

MyJpeg := TJpegImage.Create;

MyJpeg.LoadFromStream( BS );
Image1.Picture.Assign(MyJpeg);

finally
MyJpeg.Free;
BS.Free;
end;

//////////////////////////////////
Option 2 Bitmap

procedure TForm1.ADOQuery2AfterScroll(DataSet: TDataSet);
var
Bitmap : TBitmap;
BS : TADOBlobStream; //<-- this is defined in ADODB
begin
try
BS := TADOBlobStream.Create(ADOQuery2.FieldByName('picture') as
TBlobField, bmRead );
// SKIP OLE STORAGE HEADER
BS.Seek( 78, soFromBeginning );

Bitmap := TBitmap.Create;

Bitmap.LoadFromStream( BS );
Image1.Picture.Assign(BitMap);

finally
Bitmap.Free;
BS.Free;
end;
end;

Option 1 returns "...class EJPEG with message 'JPEG error #52..."

Option 2 returns "...Bitmap image is not valid..."

Option 2 however works if the field says Bitmap Image instead of Long Binary
Data.

I know the field contains images , I just do not know in what format.

Any help appreciated



.



Relevant Pages

  • Re: Loading Image in MS Access Long Binary Data
    ... viewing it in MS Access 2003 the picture field displays Long Binary data. ... // SKIP OLE STORAGE HEADER ... BS.Seek(78, soFromBeginning); ... Bitmap: TBitmap; ...
    (borland.public.delphi.database.ado)
  • Want binary data to show up as "Bitmap Image" with access/ado
    ... But when I open the table, it field says "Long binary data" and ... the text in the OLE Object says "Bitmap Image" and the form's Bound ... simulating a copy/paste operation). ...
    (microsoft.public.vb.database.ado)
  • Want binary data to show up as "Bitmap Image" with access/ado
    ... But when I open the table, it field says "Long binary data" and ... the text in the OLE Object says "Bitmap Image" and the form's Bound ... simulating a copy/paste operation). ...
    (microsoft.public.data.ado)
  • Re: Write a file from binary data
    ... > oImage.nodeTypedValue now contains a binary image (bitmap) encoded with ... > take strings as parameters. ... A variable of type "C" can contain binary data without any problem. ...
    (microsoft.public.fox.programmer.exchange)