Declaration
function Read(const FileName: string; IOParams: TIOParams = nil; bCheckUnknown: Boolean = True): boolean; overload;
function Read(Stream: TStream; FileType: TIOFileType = ioUnknown; IOParams: TIOParams = nil): boolean; overload;
function Read(Buffer: pointer; BufferSize: integer; FileType: TIOFileType = ioUnknown; IOParams: TIOParams = nil): boolean;
Description
Load an image from file or stream. This method supports all formats supported by
TImageEnIO class.
When reading from a stream you can optionally specify the
Format. If it is not specified ImageEn will determine the file type automatically.
You can optionally pass an
TIOParams object for the I/O parameters of the file (see also
ParamsEnabled). If
bCheckUnknown is true and 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. Loading errors due to a file not being available will raise an exception.
Examples
var
bmp: TIEBitmap;
begin
bmp := TIEBitmap.Create;
bmp.Read('input.jpg');
bmp.Write('output.jpg');
bmp.Free;
end;
Which is the same as...
with TIEBitmap.Create('input.jpg') do
begin
Write('output.jpg');
Free;
end;
Also, the same as...
var
bmp: TIEBitmap;
io: TImageEnIO;
begin
bmp := TIEBitmap.Create;
io := TImageEnIO.CreateFromBitmap(bmp);
io.LoadFromFile('input.jpg');
io.SaveToFile('output.jpg');
io.Free;
bmp.Free;
end;
Compatibility Notes
The parameters of TIEBitmap.Read changed for the stream overload in v6.0.0.
Code that was:
MyBmp.Read(aStream, aIOParams);
Should change to:
MyBmp.Read(aStream, ioUnknown, aIOParams);
See Also
-
Write-
Filename-
WicFastLoading