NewImage = OldImage会覆盖旧图像

编程入门 行业动态 更新时间:2024-10-25 18:23:14
本文介绍了NewImage = OldImage会覆盖旧图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Private ReadOnly oldimage As Image = ..... Private Sub drawnewimage() 昏暗的newimage As Image = oldimage *绘制新图像* 结束子 *显示旧图像* 旧图像被覆盖。如何复制而不是覆盖?

解决方案

这个问题没有多大意义,因为它是基于不理解最基本的概念之一,引用类型。赋值复制引用,而不是对象本身。你没有覆盖任何东西,你只需要复制对同一个对象的引用,然后修改同一个对象。 你想要的是什么叫做 cloning 的。请参阅,例如, https:// msdn.microsoft/en-us/library/system.drawing.image.clone%28v=vs.110%29.aspx [ ^ ]。 然而,理解问题比解决方案更重要,包括这个简单的解决方案。首先,您应该清楚地了解您的示例中会发生什么。注意:在完全理解参考和值类型之前,你不可能真正成功地进行任何编程,可能还需要更多。
-SA

Private ReadOnly oldimage As Image = ..... Private Sub drawnewimage() Dim newimage As Image = oldimage *Draw over newimage* End Sub *Display old image* The old image gets overwritten. How do copy instead of overwrite?

解决方案

The question makes little sense because it is based on not understanding one of the most fundamental concept, reference types. Assignment copies references, not objects themselves. You don't "overwrite" anything, you just copy reference to the same object and then modify the same object. What you want is called cloning. Please see, for example, msdn.microsoft/en-us/library/system.drawing.image.clone%28v=vs.110%29.aspx[^]. However, understanding the problem is much more important than the solution, including this trivial solution. First of all, you should understand clearly what happens in your example. Be careful: you cannot really successfully do any programming before you perfectly understand reference and value types, and probably a lot more.
—SA

更多推荐

NewImage = OldImage会覆盖旧图像

本文发布于:2023-08-01 08:50:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1267000.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   NewImage   OldImage

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!