如何在光栅绘图程序中实现撤消?

发布于 2024-08-02 23:40:26 字数 69 浏览 3 评论 0原文

您正在制作一个绘图程序,例如 Paint。您希望能够撤消/重做画笔描边。你会如何实施这个?

优化速度和内存。

You're making a drawing program like Paint. You want to be able to undo/redo brush strokes. How would you implement this?

Optimize for speed and memory.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

说不完的你爱 2024-08-09 23:40:26

使用 四叉树 记录画布中发生更改的部分的先前状态。
撤消时,替换四叉树中的画布状态。

Use a quadtree to record the previous state of the part of the canvas that changed.
On an undo, replace the canvas state from the quadtree.

私藏温柔 2024-08-09 23:40:26

创建画布的备份副本。选择完全包围画笔描边的矩形面片。将该补丁中包含的位图保存在新版本和备份中。您现在可以通过位块传输这些更改来撤消或重做笔画。

可能会使用大量内存。

Create a backup copy of the canvas. Choose a rectangular patch that completely surrounds the brush stroke. Save the bitmap contained in that patch in both the new version and the backup. You can now blit these changes to undo or redo the stroke.

May use a lot of memory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文