如何使用C#以另一种形式从表单中显示图像

如何使用C#以另一种形式从表单中显示图像

本文介绍了如何使用C#以另一种形式从表单中显示图像。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我已经在form1中输入了一个图像,并希望以另一种形式2处理它。我必须在form2_first下面传递form1_User_Input_Image带下划线的代码行。 请帮我这样做。 Form1I have taken input of an image in form1 and want to process it in another form2. I have to pass form1_User_Input_Image in form2_first underlined Line of code.Please help me to do this.Form1//browse image in pictureBox1 Clickprivate void pictureBox1_Click(object sender, EventArgs e){ OpenFileDialog opf = new OpenFileDialog(); opf.Filter = "Choose Image(*.jpg; *.png; *.gif)|*.jpg; *.png; *.gif"; if (opf.ShowDialog() == DialogResult.OK) { pictureBox1.Image = Image.FromFile(opf.FileName); }} Form2Form2{Image img = Image.FromFile(img);int widthThird = (int)((double)img.Width / 25.0 + 0.5);int heightThird = (int)((double)img.Height / 20.0 + 0.5);Bitmap[,] bmps = new Bitmap[20, 25];for (int i = 0; i < 20; i++) for (int j = 0; j < 25; j++) { bmps[i, j] = new Bitmap(widthThird, heightThird); Graphics g = Graphics.FromImage(bmps[i, j]); g.DrawImage(img, new Rectangle(0, 0, widthThird, heightThird), new Rectangle(j * widthThird, i * heightThird, widthThird, heightThird), GraphicsUnit.Pixel); g.Dispose(); }推荐答案 这篇关于如何使用C#以另一种形式从表单中显示图像。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-14 05:17