Declaration
function Write(const FileName: string; IOParams: TIOParams = nil): boolean; overload;
function Write(const FileName: string; FileType: TIOFileType; IOParams: TIOParams = nil): boolean; overload;
function Write(Stream: TStream; FileType: TIOFileType; IOParams: TIOParams = nil): boolean; overload;
Description
Writes the image to a file or stream. This method supports all formats supported by
TImageEnIO class.
If saving to a stream, you must specify the
FileType. When saving to a file,
FileType can be
ioUnknown, and the type will be determined by the file extension (e.g. ioJPEG for 'Image.jpeg')
You can optionally specify an
TIOParams object containing the I/O parameters of the file (see also
ParamsEnabled).
Returns true on success.
Note:
TIEBitmap only supports saving of a single frame image. To load and save images containing multiple frames, use
TIEMultiBitmapExamples
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;
// Convert an SVG file to JPEG at max size of 1000x1000 (will be adjusted to maintain aspect ratio)
var
bmp: TIEBitmap;
begin
bmp := TIEBitmap.Create;
try
bmp.Params.LoadToWidth := 1000;
bmp.Params.LoadToHeight := 1000;
bmp.Params.AutoScaleImport := True;
bmp.Read('D:\Input.svg');
bmp.Params.JPEG_Quality := 90;
bmp.Write('D:\Output.jpg');
finally
bmp.Free;
end;
end;
See Also
◼ Read◼ Filename