<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://mitov.com/wiki/skins/common/feed.css?301"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://mitov.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Method_function_IGDIPlus.IGPGraphics.Restore%28TGPGraphicsState%29_%3A_TGPGraphics</id>
		<title>Method function IGDIPlus.IGPGraphics.Restore(TGPGraphicsState) : TGPGraphics - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://mitov.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Method_function_IGDIPlus.IGPGraphics.Restore%28TGPGraphicsState%29_%3A_TGPGraphics"/>
		<link rel="alternate" type="text/html" href="https://mitov.com/wiki/index.php?title=Method_function_IGDIPlus.IGPGraphics.Restore(TGPGraphicsState)_:_TGPGraphics&amp;action=history"/>
		<updated>2026-05-11T21:27:50Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.17.0</generator>

	<entry>
		<id>https://mitov.com/wiki/index.php?title=Method_function_IGDIPlus.IGPGraphics.Restore(TGPGraphicsState)_:_TGPGraphics&amp;diff=11831&amp;oldid=prev</id>
		<title>David Alm: Automated Syncronization with Documentation</title>
		<link rel="alternate" type="text/html" href="https://mitov.com/wiki/index.php?title=Method_function_IGDIPlus.IGPGraphics.Restore(TGPGraphicsState)_:_TGPGraphics&amp;diff=11831&amp;oldid=prev"/>
				<updated>2012-10-18T17:19:06Z</updated>
		
		<summary type="html">&lt;p&gt;Automated Syncronization with Documentation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;b&amp;gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&lt;br /&gt;
This is a Beta Read Only version of this page. &lt;br /&gt;
Please review and send recommendations to [mailto:mitov@mitov.com mitov@mitov.com]. &lt;br /&gt;
We will enable the editing as soon as we are happy with the overall Wiki site.&lt;br /&gt;
&amp;lt;/span&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Class:''' [[Interface IGDIPlus.IGPGraphics|IGPGraphics]]&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
=== Delphi: ===&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
'''function''' Restore( gstate : TGPGraphicsState ) : [[Class IGDIPlus.TGPGraphics|TGPGraphics]];&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C++ Builder: ===&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[[Class IGDIPlus.TGPGraphics|TGPGraphics]] '''__fastcall''' Restore( TGPGraphicsState gstate );&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Visual C++ (MFC): ===&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 Restore(  gstate );&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
Sets the state of this [[Class IGDIPlus.TGPGraphics|TGPGraphics]] object to the state stored by a previous call to the [[Class IGDIPlus.TGPGraphics|TGPGraphics]].[[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method of this [[Class IGDIPlus.TGPGraphics|TGPGraphics]] object. &lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
Call this method to set the state of this [[Class IGDIPlus.TGPGraphics|TGPGraphics]] object&lt;br /&gt;
to the state stored by a previous call to the&lt;br /&gt;
[[Class IGDIPlus.TGPGraphics|TGPGraphics]].[[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method of this Graphics object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Examples:&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following examples show two ways to use the [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method.&lt;br /&gt;
The first example shows how to restore nested saved states,&lt;br /&gt;
and the second example shows how to restore only the first of&lt;br /&gt;
two nested saved states.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Restoring Nested Saved States&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following example sets the world transformation of a&lt;br /&gt;
Graphics object to a rotation and then saves the state of the&lt;br /&gt;
Graphics object. Next, the code calls [[Method function IGDIPlus.IGPGraphics.TranslateTransform(Single;Single;TGPMatrixOrder) : TGPGraphics|TranslateTransform]], and&lt;br /&gt;
saves the state again. Then the code calls [[Method function IGDIPlus.IGPGraphics.ScaleTransform(Single;Single;TGPMatrixOrder) : TGPGraphics|ScaleTransform]]. At&lt;br /&gt;
that point, the world transformation of the Graphics object&lt;br /&gt;
is a composite transformation: first rotate, then translate,&lt;br /&gt;
then scale. The code uses a red pen to draw an ellipse that&lt;br /&gt;
is transformed by that composite transformation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The code passes state2, which was returned by the second call&lt;br /&gt;
to [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]], to the Restore method, and draws the ellipse again&lt;br /&gt;
using a green pen. The green ellipse is rotated and&lt;br /&gt;
translated but not scaled. Finally the code passes state1,&lt;br /&gt;
which was returned by the first call to [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]], to the Restore&lt;br /&gt;
method, and draws the ellipse again using a blue pen. The&lt;br /&gt;
blue ellipse is rotated but not translated or scaled.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 var&lt;br /&gt;
   AGraphics : [[Interface IGDIPlus.IGPGraphics|IGPGraphics]];&lt;br /&gt;
   AState1, AState2 : IGPGraphicsState;&lt;br /&gt;
 &lt;br /&gt;
 begin&lt;br /&gt;
   AGraphics := [[Class IGDIPlus.TGPGraphics|TGPGraphics]].Create( ACanvas );&lt;br /&gt;
 &lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.RotateTransform(Single;TGPMatrixOrder) : TGPGraphics|RotateTransform]](30.0);&lt;br /&gt;
   AState1 = graphics.[[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]]();&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.TranslateTransform(Single;Single;TGPMatrixOrder) : TGPGraphics|TranslateTransform]](100.0, 0.0, [[Enum item IGDIPlus.TGPMatrixOrder.MatrixOrderAppend|MatrixOrderAppend]]);&lt;br /&gt;
   AState2 = graphics.[[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]]();&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.ScaleTransform(Single;Single;TGPMatrixOrder) : TGPGraphics|ScaleTransform]](1.0, 3.0, [[Enum item IGDIPlus.TGPMatrixOrder.MatrixOrderAppend|MatrixOrderAppend]]);&lt;br /&gt;
 &lt;br /&gt;
   // Draw an ellipse.&lt;br /&gt;
   // Three transformations apply: rotate, then translate, then scale.&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.DrawEllipse(IGPPen;TGPRect) : TGPGraphics|DrawEllipse]]([[Class IGDIPlus.TGPPen|TGPPen]].Create( aclRed ), 0, 0, 100, 20);&lt;br /&gt;
 &lt;br /&gt;
   // Restore to AState2 and draw the ellipse again.&lt;br /&gt;
   // Two transformations apply: rotate then translate.&lt;br /&gt;
   AGraphics.Restore(AState2);&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.DrawEllipse(IGPPen;TGPRect) : TGPGraphics|DrawEllipse]]([[Class IGDIPlus.TGPPen|TGPPen]].Create( aclGreen ), 0, 0, 100, 20);&lt;br /&gt;
 &lt;br /&gt;
   // Restore to AState1 and draw the ellipse again.&lt;br /&gt;
   // Only the rotation transformation applies.&lt;br /&gt;
   AGraphics.Restore(AState1);&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.DrawEllipse(IGPPen;TGPRect) : TGPGraphics|DrawEllipse]]( [[Class IGDIPlus.TGPPen|TGPPen]].Create( aclBlue ), 0, 0, 100, 20);&lt;br /&gt;
 end;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Restoring Only the First of Two Nested Saved States&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following example sets the world transformation of a&lt;br /&gt;
Graphics object to a rotation and then saves the state of the&lt;br /&gt;
Graphics object. Next, the code calls [[Method function IGDIPlus.IGPGraphics.TranslateTransform(Single;Single;TGPMatrixOrder) : TGPGraphics|TranslateTransform]], and&lt;br /&gt;
saves the state again. Then the code calls [[Method function IGDIPlus.IGPGraphics.ScaleTransform(Single;Single;TGPMatrixOrder) : TGPGraphics|ScaleTransform]]. At&lt;br /&gt;
that point, the world transformation of the Graphics object&lt;br /&gt;
is a composite transformation: first rotate, then translate,&lt;br /&gt;
then scale. The code uses a red pen to draw an ellipse that&lt;br /&gt;
is transformed by that composite transformation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The code passes state1, which was returned by the first call&lt;br /&gt;
to [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]], to the Restore method, and draws the ellipse again&lt;br /&gt;
using a green pen. The green ellipse is rotated but not&lt;br /&gt;
translated or scaled.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Next the code attempts to restore the state identified by&lt;br /&gt;
state2. The attempt fails because the call Restore(state1)&lt;br /&gt;
removed the information blocks identified by both state1 and&lt;br /&gt;
state2 from the stack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 var&lt;br /&gt;
   AGraphics : [[Interface IGDIPlus.IGPGraphics|IGPGraphics]];&lt;br /&gt;
   AState1, AState2 : IGPGraphicsState;&lt;br /&gt;
 &lt;br /&gt;
 begin&lt;br /&gt;
   AGraphics := [[Class IGDIPlus.TGPGraphics|TGPGraphics]].Create( ACanvas );&lt;br /&gt;
 &lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.RotateTransform(Single;TGPMatrixOrder) : TGPGraphics|RotateTransform]](30.0);&lt;br /&gt;
   AState1 = graphics.[[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]]();&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.TranslateTransform(Single;Single;TGPMatrixOrder) : TGPGraphics|TranslateTransform]](100.0, 0.0, [[Enum item IGDIPlus.TGPMatrixOrder.MatrixOrderAppend|MatrixOrderAppend]]);&lt;br /&gt;
   AState2 = graphics.[[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]]();&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.ScaleTransform(Single;Single;TGPMatrixOrder) : TGPGraphics|ScaleTransform]](1.0, 3.0, [[Enum item IGDIPlus.TGPMatrixOrder.MatrixOrderAppend|MatrixOrderAppend]]);&lt;br /&gt;
 &lt;br /&gt;
   // Draw an ellipse.&lt;br /&gt;
   // Three transformations apply: rotate, then translate, then scale.&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.DrawEllipse(IGPPen;TGPRect) : TGPGraphics|DrawEllipse]]([[Class IGDIPlus.TGPPen|TGPPen]].Create( aclRed ), 0, 0, 100, 20 );&lt;br /&gt;
 &lt;br /&gt;
   // Restore to AState1 and draw the ellipse again.&lt;br /&gt;
   // Only the rotation transformation applies.&lt;br /&gt;
   AGraphics.Restore(AState1);&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.DrawEllipse(IGPPen;TGPRect) : TGPGraphics|DrawEllipse]]([[Class IGDIPlus.TGPPen|TGPPen]].Create( aclGreen ), 0, 0, 100, 20 );&lt;br /&gt;
 &lt;br /&gt;
   // The information block identified by AState2 has been lost.&lt;br /&gt;
   // The following call to Restore has no effect because&lt;br /&gt;
   // Restore(AState1) removed from the stack the&lt;br /&gt;
   // information blocks identified by AState1 and AState2.&lt;br /&gt;
   AGraphics.Restore(AState2);&lt;br /&gt;
 &lt;br /&gt;
   // The Graphics object is still in the state identified by state1.&lt;br /&gt;
   // The following code draws a blue ellipse on top of the previously&lt;br /&gt;
   // drawn green ellipse.&lt;br /&gt;
   AGraphics.[[Method function IGDIPlus.IGPGraphics.DrawEllipse(IGPPen;TGPRect) : TGPGraphics|DrawEllipse]]([[Class IGDIPlus.TGPPen|TGPPen]].Create( aclBlue ), 0, 0, 100, 20 );&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Remarks&lt;br /&gt;
When you call the [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method of a Graphics object, an&lt;br /&gt;
information block that holds the state of the Graphics object&lt;br /&gt;
is put on a stack. The Graphics::[[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method returns a value&lt;br /&gt;
that identifies that information block. When you pass the&lt;br /&gt;
identifying value to the Restore method, the information&lt;br /&gt;
block is removed from the stack and is used to restore the&lt;br /&gt;
Graphics object to the state it was in at the time of the&lt;br /&gt;
[[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] call. Note that the identifier returned by a given call&lt;br /&gt;
to the [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method can be passed only once to the Restore&lt;br /&gt;
method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Calls to the [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method can be nested; that is, you can call&lt;br /&gt;
the [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method several times before you call the Restore&lt;br /&gt;
method. Each time you call the [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method, an information&lt;br /&gt;
block is put on the stack, and you receive an identifier for&lt;br /&gt;
the information block. When you pass one of those identifiers&lt;br /&gt;
to the Restore method, the Graphics object is returned to the&lt;br /&gt;
state it was in at the time of the [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] call that returned&lt;br /&gt;
that particular identifier. The information block placed on&lt;br /&gt;
the stack by that [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] call is removed from the stack, and&lt;br /&gt;
all information blocks placed on that stack after that [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]]&lt;br /&gt;
call are also removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Calls to the [[Method function IGDIPlus.IGPGraphics.BeginContainer(TGPRect;TGPRect;TGPUnit) : TGPGraphicsContainer|BeginContainer]] method place information blocks&lt;br /&gt;
on the same stack as calls to the [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] method. Just as a&lt;br /&gt;
Restore call is paired with a [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] call, an [[Method function IGDIPlus.IGPGraphics.EndContainer(TGPGraphicsContainer) : TGPGraphics|EndContainer]] call&lt;br /&gt;
is paired with a [[Method function IGDIPlus.IGPGraphics.BeginContainer(TGPRect;TGPRect;TGPUnit) : TGPGraphicsContainer|BeginContainer]] call.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note When you call Restore, all information blocks placed on&lt;br /&gt;
the stack (by [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] or by [[Method function IGDIPlus.IGPGraphics.BeginContainer(TGPRect;TGPRect;TGPUnit) : TGPGraphicsContainer|BeginContainer]]) after the&lt;br /&gt;
corresponding call to [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] are removed from the stack.&lt;br /&gt;
Likewise, When you call [[Method function IGDIPlus.IGPGraphics.EndContainer(TGPGraphicsContainer) : TGPGraphics|EndContainer]], all information blocks&lt;br /&gt;
placed on the stack (by [[Method function IGDIPlus.IGPGraphics.Save() : TGPGraphicsState|Save]] or by [[Method function IGDIPlus.IGPGraphics.BeginContainer(TGPRect;TGPRect;TGPUnit) : TGPGraphicsContainer|BeginContainer]]) after the&lt;br /&gt;
corresponding call to [[Method function IGDIPlus.IGPGraphics.BeginContainer(TGPRect;TGPRect;TGPUnit) : TGPGraphicsContainer|BeginContainer]] are removed from the&lt;br /&gt;
stack.&lt;/div&gt;</summary>
		<author><name>David Alm</name></author>	</entry>

	</feed>