Re: Loading Image in MS Access Long Binary Data
- From: Brian Bushay TeamB <BBushay@xxxxxxxxx>
- Date: Sun, 05 Mar 2006 21:27:46 -0600
I have a MS Access table containing a stockcodes and an Images. WhenTry this reference
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
http://delphi.about.com/od/database/l/aa030601a.htm
--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx
.
- References:
- Loading Image in MS Access Long Binary Data
- From: Robert T
- Loading Image in MS Access Long Binary Data
- Prev by Date: Re: display the record number on dbgrid
- Next by Date: Re: batchoptimistic referesh data in second table in the join
- Previous by thread: Loading Image in MS Access Long Binary Data
- Next by thread: Re: Betterado error in Delphi 2006
- Index(es):
Relevant Pages
|