ImageEn, unit imageenio

TImageEnIO.LoadFromFile

TImageEnIO.LoadFromFile


Declaration

                                                                        function LoadFromFile(const FileName: WideString; bCheckUnknown: Boolean = True): Boolean; overload;
function LoadFromFile(const FileName: WideString; FileFormat: TIOFileType): Boolean; overload;


Description

Loads an image from the specified file. It recognizes the image format from the filename extension (if ImageFormat is not specified).
The source can be also an URL if it has the form 'http://' or on an attached device if WPD: prefix is included.

FileName is the file name including extension.
FileFormat specifies the image format. If specified as ioUnknown, it will use the file's extension.
bCheckUnknown if the file extension is not known or is incorrect (e.g. a GIF file named MyImage.jpg), then loading will be attempted by analyzing the file content (in the same way as LoadFromFileAuto)

Result will be false if the file is not a recognized file type (and Aborting will be true). Loading errors due to a file not being available will raise an exception.

Note:
 You can abort loading by setting Aborting to true
 By default, this routine will fail for files with an invalid extension (e.g. a GIF file named MyImage.jpg) or unknown extension. To avoid this you can use the bCheckUnknown overload or LoadFromFileAuto
 Can load IEV (TImageEnVect objects) and IEN+IEV formats when AttachedImageEn is TImageEnView or TImageEnVect
 You can use the format Filename::ImageIndex as a shortcut method to specify an image index to load, e.g. "D:\MultiImage.tiff::5"


Example

// Load the second image in the MyImage.tif file
ImageEnView1.IO.Params.TIFF_ImageIndex := 1;
ImageEnView1.IO.LoadFromFile( 'D:\MyImage.tif' );

// Load a file even if this file extension is incorrect
ImageEnView1.IO.LoadFromFile( sFilename, True );

// Load an image on an attached device
ImageEnView1.IO.LoadFromFile( 'WPD:GM1913\Internal shared storage\im3.jpg' );


See Also

 LoadFromFileAuto
 WicFastLoading
 Aborting