在 .NET 中的图像上绘图 - 如何擦除?

发布于 2024-09-10 10:36:10 字数 74 浏览 2 评论 0原文

我计划允许用户使用鼠标在图像上绘制形状和线条。如果背景是纯色的,则构建橡皮擦工具非常容易(只需填充背景颜色)。但是如何以图像为背景呢?

I'm planning to allow user drawing shapes and lines on image using mouse. If the background is solid, it's quite easy to build the eraser tool (simply fill with background color). But how to make it with image as background?

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

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

发布评论

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

评论(2

初雪 2024-09-17 10:36:10

不太确定我是否遵循。但是,如果您想擦除在图像上绘制的内容,则可以通过将图像拉回来来擦除。如果您使用TextureBrush 类,这很容易做到。我认为您需要 TextureBrush(Image, Rectangle) 重载来创建它。将背景图像作为第一个参数传递,将该图像的边界矩形作为第二个参数传递。

Not quite sure I follow. But if you want erase something that was drawn on top of an image then you can erase by drawing the image back. That's easy to do if you use the TextureBrush class. I think you need the TextureBrush(Image, Rectangle) overload to create it. Pass the background image as the first argument, the bounding rectangle of that image as the second argument.

软糯酥胸 2024-09-17 10:36:10

您必须保持分层结构。用户将看到的将是输出的“预览”。当您将图像导出为不支持图层的格式时,您将合并图层。

You have to maintain a layers structure. What the user will see will be a "preview" of the output. You'll merge the layers when you export the image to a format than do not support layers.

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