IImageList.SaveToStream2

Syntax

SaveToStream2(Stream: IIOStream): Boolean;

Parameters

Stream. The stream, to which images are saved.

Description

The SaveToStream2 method saves images to the stream keeping information on their semi-transparency.

Comments

After executing the method all images loaded to the component are saved to the specified stream using a special format. This format supports saving information on images semi-transparency. The images can be further loaded from the stream using the LoadFromStream2 method.

Example

Executing this example requires a form, a button named Button1 on the form, the ImageList component named ImageList1, and some components that use images of the ImageList1 component. Images with semi-transparent sections are loaded to ImageList1.

Class TESTForm: Form
    Button1: Button;
    ImageList1: ImageList;
    Img: ImageList;
    TestToolbar: Toolbar;

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        Str: IMemoryStream;
    Begin
        Self.BeginUpdate;
        Str := New MemoryStream.Create;
        Img := New ImageList.Create;
        ImageList1.SaveToStream2(Str);
        Img.LoadFromStream2(Str);
        TestToolbar := New Toolbar.Create;
        TestToolbar.Parent := Self;
        TestToolbar.Images := Img;
        TestToolbar.BeginUpdate;
        //...Further toolbar setup 
        TestToolbar.EndUpdate;
        Self.EndUpdate;
    End Sub Button1OnClick;

End Class TESTForm;

Clicking the button dynamically creates a toolbar. The ImageList component is also created dynamically to store the images that will be used by panel controls. Images are loaded to the component together with information on semi-transparency.

See also:

IImageList