在 .NET 中的图像上绘图 - 如何擦除?
我计划允许用户使用鼠标在图像上绘制形状和线条。如果背景是纯色的,则构建橡皮擦工具非常容易(只需填充背景颜色)。但是如何以图像为背景呢?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不太确定我是否遵循。但是,如果您想擦除在图像上绘制的内容,则可以通过将图像拉回来来擦除。如果您使用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.
您必须保持分层结构。用户将看到的将是输出的“预览”。当您将图像导出为不支持图层的格式时,您将合并图层。
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.