Loading Image in MS Access Long Binary Data
- From: "Robert T" <someone@xxxxxxxxxxxxx>
- Date: Sat, 4 Mar 2006 18:10:26 +0200
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
.
- Follow-Ups:
- Re: Loading Image in MS Access Long Binary Data
- From: Brian Bushay TeamB
- Re: Loading Image in MS Access Long Binary Data
- Prev by Date: Re: Display data in a DBGrid
- Next by Date: Re: Create a User/Password to a Acces DB
- Previous by thread: Why loosing grid.datasource value
- Next by thread: Re: Loading Image in MS Access Long Binary Data
- Index(es):
Relevant Pages
|