Graphics.Save 与 Graphics.BeginContainer
Graphics.Save
与 Graphics.BeginContainer
有何不同?
How is Graphics.Save
different from Graphics.BeginContainer
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请查看此处:
take a look here:
也许我可以从MSDN的一些例子给出解释。我的MSDN版本是Visual Studio 2008 SP1。在MSDN的编辑中输入关键字“Nested Graphics Containers”就可以找到示例。
其解释如下:
从上面复制的内容来看,关键词是“累计”和“交集”。因此,我认为这可以成为理解BeginContainer函数的一种方式。
完整的 MSDN 文章位于此处。
Maybe I can give a explanation from some examples of MSDN. The version of my MSDN is Visual Studio 2008 SP1. And the examples can be found when you enter the keyword "Nested Graphics Containers" in the edit of MSDN.
And its explanation is below:
From the content copied above, the keywords are "cumulative" and "intersection". Therefore, I think it can be a way to understand the BeginContainer function.
Full MSDN article available here.
图形.保存方法
保存此 Graphics 的当前状态并使用 GraphicsState 标识保存的状态。
Graphics.BeginContainer方法
使用此 Graphics 对象的当前状态保存图形容器,并打开并使用新的图形容器。
备注
调用BeginContainer方法会将信息块与调用Save方法放置在同一堆栈上。正如 Restore 调用与 Save 调用配对一样,EndContainer 方法调用与 BeginContainer 方法调用配对。
当您调用Restore方法时,在对Save方法的相应调用之后放置在堆栈上的所有信息块(通过Save方法或通过BeginContainer方法)都将从中删除堆栈。同样,当您调用 EndContainer 方法时,所有信息块(通过 Save 方法或通过 BeginContainer 方法)在对 BeginContainer 方法的相应调用将从堆栈中删除。
详情请参阅
http://msdn.microsoft.com/en-我们/library/system.drawing.graphics.save.aspx
Graphics.Save Method
Saves the current state of this Graphics and identifies the saved state with a GraphicsState.
Graphics.BeginContainer Method
Saves a graphics container with the current state of this Graphics object and opens and uses a new graphics container.
Remarks
Calls to the BeginContainer method place information blocks on the same stack as calls to the Save method. Just as a Restore call is paired with a Save call, a EndContainer method call is paired with a BeginContainer method call.
When you call the Restore method, all information blocks placed on the stack (by the Save method or by the BeginContainer method) after the corresponding call to the Save method are removed from the stack. Likewise, When you call the EndContainer method, all information blocks placed on the stack (by the Save method or by the BeginContainer method) after the corresponding call to the BeginContainer method are removed from the stack.
See details on
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.save.aspx
BeginContainer()
和Save()
之间的区别仅在于BeginContainer()
将所有渲染属性重置为其默认状态。简而言之,
BeginContainer()
执行以下操作:Save()
以保存图形的当前状态您可以在 文档的备注部分找到有关它的提示:
PS:这不是完整的答案,因为我们仍然不知道重置为默认状态的属性的完整列表,不幸的是文档对此只字未提。
The difference between
BeginContainer()
andSave()
is only thatBeginContainer()
resets all rendering properties to their default state.So in brief
BeginContainer()
does following:Save()
internally to save the current state of graphicsYou can find hint about it in the remarks section of documentation:
P.S.: This is not complete answer because we still don't know the full list of properties that are reset to default state, unfortunately documentation say nothing about it.