如何将所有图片框控件(子图片框)合并到父图片框中的一个图像中? [英] How Do I Merge All Picture Box Controls (Child Picture Box) Into One Image In Parent Picture Box ?

查看:95
本文介绍了如何将所有图片框控件(子图片框)合并到父图片框中的一个图像中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//////////////////////////////////////////////////// 
 pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
 pictureBox1.ImageLocation = Application.StartupPath + "\\pic\\schemaCar.png";
////////////////////////////////////////////////////
 PictureBox picture1 = new PictureBox();
 picture1.SizeMode = PictureBoxSizeMode.StretchImage;
 picture1.Image = new Bitmap(Application.StartupPath + "\\pic\\" + action + ".jpg");
 picture1.Location = new System.Drawing.Point(115, 75);
 picture1.Size = new System.Drawing.Size(17, 60);
 pictureBox1.Controls.Add(picture1);
///////////////////////////////////////////////////
 PictureBox picture2 = new PictureBox();
 picture2.SizeMode = PictureBoxSizeMode.StretchImage;
 picture2.Image = new Bitmap(Application.StartupPath + "\\pic\\" + action + ".jpg");
 picture2.Location = new System.Drawing.Point(82, 75);
 picture2.Size = new System.Drawing.Size(17, 60);
 pictureBox1.Controls.Add(picture2);
 //////////////////////////////////////////////////
 PictureBox picture3 = new PictureBox();
 picture3.SizeMode = PictureBoxSizeMode.StretchImage;
 picture3.Image = new Bitmap(Application.StartupPath + "\\pic\\" + action + ".jpg");
 picture3.Location = new System.Drawing.Point(242, 75);
 picture3.Size = new System.Drawing.Size(17, 59);
 pictureBox1.Controls.Add(picture3);
//////////////////////////////////////////////////
 pictureBox1.Image.Save(@"C:\New folder\picture.jpg");
/////////////////////////////////////////////////



此代码只保存在图片框中的第一个图像,但我需要合并所有图像并保存它......

以上cod:显示picturebox1中的所有图像,但我无法将所有图像保存在一张图片中


this code just save first image in picturebox, but i need merge all images and save it......
above cod: show all images in picturebox1, but i can't save all images in one picture to memory

推荐答案

尽管问题不明确,但它清楚地表明你根本不应该使用 PictireBox 。请查看我过去的答案:

在其中附加图片图片框 [ ^ ],

画一个矩形C# [ ^ ],

如何从旧图纸中清除面板 [ ^ ]。



参见:

什么样的俏皮方法是Paint? (DataGridViewImageCell.Paint(...)) [ ^ ],

在面板上捕获绘图 [ ^ ],

mdi子表单之间的绘制线 [ ^ ]。



-SA
Even though the question is not clear, it clearly indicates that you should not use PictireBox at all. Please see my past answers:
Append a picture within picturebox[^],
draw a rectangle in C#[^],
How do I clear a panel from old drawing[^].

See also:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
capture the drawing on a panel[^],
Drawing Lines between mdi child forms[^].

—SA


您是否从我对第一个问题的回答中学到了什么:



如何保存在我的Pictrebox中添加的所有Picturebox控件的一个图像?



我认为谢尔盖是对的:这是一个你不应该尝试使用PictureBox控件;请查看谢尔盖的回答以及他提供的链接。



PictureBox控件是一个图像的容器。应使用PictureBox的Image属性或ImageLocation属性将该图像分配给PictureBox。



您可以将控件添加到PictureBox的ControlCollection中。一个工具PictureBox继承,因为它的祖先是控制类...并不意味着你应该使用它来托管多个其他PictureBoxes ......或任何其他控件。



使用Panel或其他ContainerControl控件,它允许将多个PictureBox或其他控件添加到其ControlsCollection。



之前发布您的下一个问题,请搜索CodeProject以获取有关图像和图像处理的文章:这里有许多优秀的资源。
Did you learn anything from my answer to your first question:

How Do I Save One Image Of All Picturebox Controls Which Added In My Pictrebox?

I think Sergey is right: this is one case you should not try and work with the PictureBox Control; please review Sergey's answer(s), and the links he provided.

A "PictureBox" Control is a container for one image. That image should be assigned to the PictureBox using the 'Image property of the PictureBox, or the ImageLocation property.

The fact you can add Controls to the PictureBox's ControlCollection ... a facility PictureBox inherits since its ancestor is the Control Class ... does not mean you should use it to host multiple other PictureBoxes ... or any other Control.

Use a Panel, or other ContainerControl Control, which allows multiple PictureBoxes, or other Controls, to be added to its ControlsCollection.

Before posting your next question, please do search CodeProject for articles on images, and image manipulation: there are many excellent resources here.


这篇关于如何将所有图片框控件(子图片框)合并到父图片框中的一个图像中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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