ImageEn, unit iexDBBitmaps

TIEDBBitmap.DataSource

TIEDBBitmap.DataSource


Declaration

property DataSource: TDataSource;


Description

Link the bitmap with a dataset. You will also need to set FilenameField or ImageBlobField.

If AutoLoad is enabled the content will automatically update as the attached table changes. Otherwise you can call LoadImage.


Examples

// Display content of a table where images are stored in a blob field
fDBBitmap := TIEDBBitmap.create();
fDBBitmap.DataSource := DataSource1;
fDBBitmap.ImageBlobField := 'ImageBlob';
ImageEnView1.SetExternalBitmap( fDBBitmap );

// Display content of a table where images are stored in a blob field and name of image is stored in "ImageName" field
fDBBitmap := TIEDBBitmap.create();
fDBBitmap.DataSource := DataSource1;
fDBBitmap.FilenameField := 'ImageName';
fDBBitmap.ImageBlobField := 'ImageBlob';
ImageEnView1.SetExternalBitmap( fDBBitmap );

// Display content of a table where images are stored in a folder and their path and filename is referenced by the "ImageFilename" field
fDBBitmap := TIEDBBitmap.create();
fDBBitmap.DataSource := DataSource1;
fDBBitmap.FilenameField := 'ImageFilename';
ImageEnView1.SetExternalBitmap( fDBBitmap );

// Display content of a table where images are stored in a folder named "My Folder" and their filename is referenced by the "ImageName" field
fDBBitmap := TIEDBBitmap.create();
fDBBitmap.DataSource := DataSource1;
fDBBitmap.ImagePath  := 'C:\My Folder\';
fDBBitmap.FilenameField := 'ImageName';
ImageEnView1.SetExternalBitmap( fDBBitmap );


Note: Don't forget to free the object...
procedure TMainForm.FormDestroy(Sender: TObject);
begin
  FreeAndNil( fDBBitmap );
end;