IGxGraphics.RestoreState

Syntax

RestoreState(Value: Integer);

Parameters

Value. Index of the saved state of the graphic object.

Description

The RestoreState method restores the graphic object from the stack.

The state of the graphic object is saved by the SaveState method.

Fore Example

Executing the example requires a form with the button named Button1 and the ImageBox component named ImageBox1. Add links to the Drawing, Forms system assemblies.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);

Var

BMP: IGxBitmap;

Graph: IGxGraphics;

GraphClass: GxGraphicsClass;

Font: IGxFont;

Brush: IGxBrush;

i: Integer;

Begin

//Create a bitmap

BMP := GxBitmap.CreateNew(ImageBox1.ClientWidth, ImageBox1.ClientHeight, GxPixelFormat.Unknown);

Font := New GxFont.Create("Times New Roman", 16, GxFontStyle.BoldItalic, GxUnit.World);

Brush := New GxSolidBrush.Create(GxColor.FromName("Red"));

GraphClass := New GxGraphics.Create;

Graph := GraphClass.FromImage(BMP);

//Save

i := Graph.SaveState;

Graph.SetScale(5, 5);

Graph.DrawTextW(The first inscription, Font, Brush, 0, 0);

Graph.RestoreState(i);

Graph.DrawTextW(The second inscription, Font, Brush, 0, 0);

ImageBox1.Image := BMP;

End Sub Button1OnClick;

After executing the example clicking the button in the ImageBox component displays a new bitmap, which state parameters are stored in the stack. The image zoom is changed and text message according to the settings is displayed. After displaying the first message, the bitmap state parameters are restored and the second message is displayed.

See also:

IGxGraphics