ImageEn, unit iexBitmaps

TIOParams.Read

TIOParams.Read


Declaration

function Read(const FileName: WideString; Format: TIOFileType = ioUnknown): Boolean; overload;
function Read(const FileName: WideString; bUseExtension: Boolean): Boolean; overload;
function Read(Stream: TStream; Format: TIOFileType = ioUnknown): Boolean; overload;
function Read(Buffer: Pointer; BufferSize: Integer; Format: TIOFileType = ioUnknown): Boolean; overload;


Description

Reads the properties of an image. Result is false if a loading error is encountered due to a corrupt or unknown image format.

FileName is the file name with full path.
Format is the file format that the stream or file contains. If ioUnknown is specified then the file content is analyzed to determine the format.
bUseExtension determines that the file format is based on the extension of the file, e.g. image.jpeg will be processed as ioJPEG format.


Examples

// Load the parameters of an image (which may be a BMP file, but we will examine the content to be sure)
IOParams.Read( 'C:\alfa.bmp' );
Label1.Caption := 'alfa.bmp has ' + inttostr(IOParams.BitsPerSample) + ' bits per sample';

// Load the parameters of a BMP
IOParams.Read( 'C:\alfa.bmp', ioBMP );
Label1.Caption := 'alfa.bmp has ' + inttostr(IOParams.BitsPerSample) + ' bits per sample';

// Load the parameters of a file. It will be assumed to a BMP because of the file extension
IOParams.Read( 'C:\alfa.bmp', True );
Label1.Caption := 'alfa.bmp has ' + inttostr(IOParams.BitsPerSample) + ' bits per sample';

// Read the count of the images in a file (Same as IEGetFileFramesCount)
function GetImageCount(const FileName: WideString): Integer;
var
  iop : TIOParams;
begin
  Result := -1;
  iop := TIOParams.Create( Nil );
  If iop.Read( FileName ) then
    Result := iop.ImageCount;
  iop.Free;
end;