ImageEn, unit iemview

TImageEnMView.EnsureImageLoaded

TImageEnMView.EnsureImageLoaded


Declaration

procedure TImageEnMView.EnsureImageLoaded(idx: integer; ParamsOnly: Boolean = False);


Description

If the content of the TImageEnMView is being loaded on demand (e.g. you are using LoadFromFileOnDemand) then the image properties such as ImageWidth and ImageHeight, and I/O parameters will not be valid until the image has loaded. Calling EnsureImageLoaded will force an image to be loaded so you can access its properties.
Naturally calling EnsureImageLoaded too often (e.g. for all images) would defeat the purpose of loading on demand and affect performance.
If ParamsOnly = true, then only the properties of the image, such as its dimension are loaded.


Example

// Get the dimensions of the selected image
if ImageEnMView1.SelectedImage >= 0 then
begin
  ImageEnMView1.EnsureImageLoaded( ImageEnMView1.SelectedImage );
  StatusBar.Text [ 0 ] := ImageEnMView1.ImageWidth[ ImageEnMView1.SelectedImage ] + ' x ' + ImageEnMView1.ImageHeight[ ImageEnMView1.SelectedImage ];
end;

// Read the Photoshop description of the selected image
if ImageEnMView1.SelectedImage >= 0 then
begin
  ImageEnMView1.EnsureImageLoaded( ImageEnMView1.SelectedImage );
  StatusBar.Text [ 1 ] := ImageEnMView1.MIO.Params[ ImageEnMView1.SelectedImage ].ReadIPTCField(PhotoShop_IPTC_Records, IPTC_PS_Caption);
end;