SaveToDoc(Value: String; BgColor: IGxColor): Boolean;
Value. Path to the file where the image should be stored.
BgColor. Image background color. If Null is passed as the background color, color is selected randomly.
The SaveToDoc method saves all images from the collection to the file, which path is passed as the input parameter.
All images are saved as a horizontal series. The method results in the attribute that images are saved successfully.
Executing the example requires a form with the button named Button1, the ImageList component named ImageList1 and a set of images in the collection. For details about image loading to the component see the ImageList section.
Add links to the Drawing, Forms, and Io system assemblies.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
ImgList: IGxImageList;
Str: IIOStream;
Begin
ImgList := New GxImageList.Create;
Str := New MemoryStream.Create;
// Send icons to collection of images via the stream
ImageList1.SaveToStream(Str, GxColor.FromName("White"));
ImgList.LoadFromStream(Str);
// Remove one image from collection and save the rest to file
ImgList.Remove(1);
ImgList.SaveToDoc("C:\temp\1.bmp", GxColor.FromName("White"));
// Display the number of images in collection and sizes of the first image to the console
Debug.WriteLine("Number of images in collection: " + ImgList.Count.ToString);
Debug.WriteLine("Size:");
Debug.WriteLine("Width: " + ImgList.Item(0).Size.Width.ToString);
Debug.WriteLine("Height: " + ImgList.Item(0).Size.Height.ToString);
End Sub Button1OnClick;
Clicking the button removes an image from the collection and all of the rest images are saved as horizontal series to the selected file:
![]()
The console window displays the number of images in the file and sizes of the first image.
See also: