Declaration
procedure SaveToFileWIC(const FileName: WideString; FileFormat: TIOFileType);
Description
Saves the current image to a file using
TIEWICWriter.
Set
FileFormat to a WIC supported encoder, e.g. ioDDS or ioJPEG
Note:
◼Relevant formats can saved losslessly by enabling
HDP_Lossless. Otherwise the quality can be specified using
HDP_ImageQuality
◼Some WIC formats require installation of a codec from the Microsoft store
◼See
WIC_Save_FileTypes for a list of WIC supported saving types
◼If an internal save error is encountered
Aborting will return true. Saving issues due to insufficient write permissions and disk write failures will raise an exception.
◼To abort while saving set
Aborting to true
// Save an image to a DirectDraw Surface stream using WIC
ImageEnView1.IO.SaveToFileWIC( 'D:\image.dds', ioDDS );
// Save an image to a JPEG stream using WIC
ImageEnView1.IO.SaveToFileWIC( 'D:\image.jpeg', ioJPEG );
Heif Size Comparisons
ImageEnView1.IO.LoadFromFile( 'D:\Alpha.png' ); // Original PNG - 335KB

ImageEnView1.IO.Params.HDP_ImageQuality := 1.0;
ImageEnView1.IO.SaveToFileWIC( 'D:\image100.Heif' ); // 85KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.9;
ImageEnView1.IO.Params.HDP_Lossless := False;
ImageEnView1.IO.SaveToFileWIC( 'D:\image90.Heif' ); // 68KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.7;
ImageEnView1.IO.SaveToFileWIC( 'D:\image70.Heif' ); // 40KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.5;
ImageEnView1.IO.SaveToFileWIC( 'D:\image50.Heif' ); // 21KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.2;
ImageEnView1.IO.SaveToFileWIC( 'D:\image20.Heif' ); // 7KB

ImageEnView1.IO.Params.HDP_ImageQuality := 0.01;
ImageEnView1.IO.SaveToFileWIC( 'D:\image01.Heif' ); // 3KB

See Also
◼SaveToStreamWIC
◼LoadFromFileWIC
◼WIC_Save_FileTypes