使用重叠控件在PictureBox中保存图像 [英] Save Image in PictureBox with overlapping Controls

查看:130
本文介绍了使用重叠控件在PictureBox中保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,用户可以在其中选择图片框中的图像。

I am developing an application in which user can select an image in a picture box.

之后,他可以右键单击图像并添加一个用户控件,该控件将再次显示图像和一些文本。此用户控件可以添加任意次。

After that he can right click on the image and add a user control which will again display an Image along with some text. This user control can be added any number of times.

用户还可以根据需要重新定位用户控件。

User can also re-position the user controls as per need.

所有这些功能都已实施并且运行正常。

All this functionality has been implemented and is working fine.

现在,要求是将图像与用户控件一起保存。

您可以在上面看到需要保存的完整图像。背面图像是图片框图像和用户控件(带有文本的小图像)。

Above you can see the complete image which needs to be saved. Back image is the picture box image and the user control (small images with text).

当用户点击保存按钮时,图像应该保存在他的磁盘上单个图片。

When user will click on save button the image should get saved on his disk as a single image.

这是 C#开发的 Windows应用程序

This is a windows application developed in C#.

我想知道是否可以实现此功能。如果是,那么请指导我正确的方向。

I want to know that whether this functionality can be achieved or not. If yes, then please guide me in the right direction.

推荐答案

如果您创建位图的副本,那么使用图形。 DrawImage()你可以将这些图像绘制到它上面。你需要计算这些控件的位置。

If you create a copy of the bitmap then with the Graphics.DrawImage() you can draw those images onto it. You need to calculate the position of those controls.

在这里查看DrawImage: http://msdn.microsoft.com/en-us/library/42807xh1.aspx

Look here for DrawImage: http://msdn.microsoft.com/en-us/library/42807xh1.aspx

示例:

Bitmap copy = new Bitmap(OriginalBitmap);

Graphics g = Graphics.FromImage(copy);

g.DrawImage(arrowBitmap, new Point(..));

copy.Save(...);

这篇关于使用重叠控件在PictureBox中保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆