How To ... (High Level)How To ... (High Level)High Level interface in the current version is made of
the base class TBaseImage and its two descendants
TSingleImage and TMultiImage.
More information on the current state of high level interface
can be found in
Usage/High Level Interface
section.You can learn how to use high level interface from the
following code fragments or (more useful) high level
Pascal Demos.
// high level interface test
uses
ImagingTypes,
// high level classes are declared in this unit
ImagingClasses;
var
// this is one level image container
SImg: TSingleImage;
// this is multi level image container
MImg: TMultiImage;
begin
// new 400x300x24 image is created
SImg := TSingleImage.CreateFromParams(400, 300, ifR8G8B8);
// resize image
SImg.Resize(512, 384, rfBicubic);
// you can find out whether image is valid or not this way:
if SImg.Valid then
WriteLn('Image is valid!');
// you are free to use low level functions on high level classes
// you can use ImageData property to get access to underlying structure
SwapChannels(SImg.ImageDataPointer^, ChannelRed, ChannelGreen);
// image can be converted to another format by simply setting Format property
SImg.Format := ifIndex8;
// extended format info is accessible trough FormatInfo property
WriteLn('Image has ', SImg.FormatInfo.PaletteEntries, ' palette entries');
// new multi image without parameters is created (default sized 1 level image
// will be created)
MImg := TMultiImage.Create;
// single image is assigned to multi image - multi image will now have
// one level identical to source single image
MImg.Assign(SImg);
// single image is resized
SImg.Width := SImg.Width * 2;
// new level is added to multi image (SImg is cloned)
MImg.AddLevel(SImg);
// single image is converted
SImg.Format := ifR32F;
// new level is inserted to multi image at index 0 (SImg is cloned)
MImg.InsertLevel(0, SImg);
// all levels of multi image are written to stream
MImg.SaveMultiToStream('tga', SomeStream);
// images are freed
SImg.Free;
MImg.Free;
end.