ImageEn, unit iewic

TIEWICReader.Open

TIEWICReader.Open


Declaration

function Open(Stream: TStream; FileType: TIOFileType = ioUnknown): boolean; overload;
function Open(const FileName: WideString; FileType: TIOFileType = ioUnknown): boolean; overload;


Description

Opens a stream or file, enabling subsequent calls to GetFrame. For streams, the TIOFileType should be specified (one of: ioBMP, ioPNG, ioICO, ioJPEG, ioGIF, ioTIFF, ioHDP, ioDDS, ioHEIF, ioWEBP, ioWIC). For files, the TIOFileType is based on the file extension if not specified. Pass ioUnknown to have the format guessed by content.
You should call Free or Close in order to terminate reading.

Note: FileType should generally be passed as ioUnknown so the stream content is used to determine the best decoder to use (using IWICImagingFactory::CreateDecoderFromStream). Otherwise a decoder is explicitly selected for the file type


Example

// Load an HDP file
with TIEWICReader.Create do
begin
  Open( 'C:\input.wdp' );
  GetFrame(0, ImageEnView1.IEBitmap, ImageEnView1.IO.Params);
  Free; // Calls Close() implicitly
end;
ImageEnView1.Update;

// Load a DirectDraw Surface file
with TIEWICReader.Create do
begin
  Open( 'C:\input.dds' );
  GetFrame(0, ImageEnView1.IEBitmap, ImageEnView1.IO.Params);
  Free; // Calls Close() implicitly
end;
ImageEnView1.Update;