TIEDBBitmap is a descendant of TIEBitmap, but it links to a datasource to provide access to images stored in a database table.
TIEDBBitmap supports both images stored within the database as a blob (by setting ImageBlobField) or images stored locally and referenced by a filename field (by setting only FilenameField). You will need to set DataSource.
There are two ways you can use TIEDBBitmap:
• Connected to a TTable
By setting the DataSource and ImageBlobField or FilenameField, the TIEDBBitmap will be connected to the database and the content will update with the movement and changes on the table, either automatically (AutoLoad is true) or manually (by calling LoadImage). This is generally used to create a data-aware TImageEnView by setting the external bitmap to a TIEDBBitmap. // Create DB Aware TImageEnView procedure TMainForm.FormCreate(Sender: TObject); begin ... Open a database table ...
procedure TMainForm.FormDestroy(Sender: TObject); begin FreeAndNil( fDBBitmap ); end;
• As an adhoc Bitmap with database access
Use TIEDBBitmap to retrieve images embedded in a database blob field using the data-aware overload of Read. // Extract an image from a database and save it MyBMP := TIEDBBitmap.Create(); MyBMP.Read( MyTableImageBlob ); MyBmp.Write( 'D:\MyBlobImage.jpeg' ); MyBmp.Free;