将416x416图像分割成16个图像 [英] Split a 416x416 image into 16 pieces

查看:125
本文介绍了将416x416图像分割成16个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我使用下面的代码将图像分成16个部分。但是它没有工作......请帮助我......

在这里下载图片和结果... < br $> b $ b

https://drive.google .com / file / d / 0B_1aiVUSMOJocEIyb0dnWEZYak0 / view?usp = sharing [ ^ ]

https://drive.google.com/file/d/0B_1aiVUSMOJobEVXLTFiYlRaYU0/view?usp=sharing [ ^ ]

代码是..

 private void button1_Click (对象发送者,EventArgs e)
{
图片img = Image.FromFile(@C:\ Users \ Manuprasad M \Downloads\kriste正stewart_416x416.jpg);
Bitmap [,] bmps = new Bitmap [4,4];
for(int i = 0; i< 4; i ++)
for(int j = 0; j< 4; j ++)
{
bmps [i,j ] =新位图(104,104);
Graphics g = Graphics.FromImage(bmps [i,j]);
g.DrawImage(img,new Rectangle(0,0,104,104),new Rectangle(j * 104,i * 104,104,104),GraphicsUnit.Pixel);
g.Dispose();
}
pictureBox1.Image = bmps [0,0];
pictureBox2.Image = bmps [0,1];
pictureBox3.Image = bmps [0,2];
pictureBox4.Image = bmps [0,3];
pictureBox5.Image = bmps [1,0];
pictureBox6.Image = bmps [1,1];
pictureBox7.Image = bmps [1,2];
pictureBox8.Image = bmps [1,3];
pictureBox9.Image = bmps [2,0];
pictureBox10.Image = bmps [2,1];
pictureBox11.Image = bmps [2,2];
pictureBox12.Image = bmps [2,3];
pictureBox13.Image = bmps [3,0];
pictureBox14.Image = bmps [3,1];
pictureBox15.Image = bmps [3,2];
pictureBox16.Image = bmps [3,3];
}

解决方案

此处显示的代码没有任何问题!还发生了其他事情,它将复制到每个PictureBox中的位图区域向右移动并截断它。



检查你的PictureBox以确保它们的大小为104,104并且'SizeMode设置为正常。另外,请检查以确保PictureBox没有设置'Anchor或'Dock属性,以便在运行时重新调整它们所在的Form / ContainerControl时它们将重新调整大小。

Hi I used the below code for split an image into 16 pieces.But its not working..Please help me...
Download Picture and results here...

https://drive.google.com/file/d/0B_1aiVUSMOJocEIyb0dnWEZYak0/view?usp=sharing[^]
https://drive.google.com/file/d/0B_1aiVUSMOJobEVXLTFiYlRaYU0/view?usp=sharing[^]
Code is..

private void button1_Click(object sender, EventArgs e)
        {
            Image img = Image.FromFile(@"C:\Users\Manuprasad M\Downloads\kristen-stewart_416x416.jpg"); 
            Bitmap[,] bmps = new Bitmap[4, 4];
            for (int i = 0; i < 4; i++)
                for (int j = 0; j < 4; j++)
                {
                    bmps[i, j] = new Bitmap(104, 104);
                    Graphics g = Graphics.FromImage(bmps[i, j]);
                    g.DrawImage(img, new Rectangle(0, 0, 104, 104), new Rectangle(j * 104, i * 104, 104, 104), GraphicsUnit.Pixel);
                    g.Dispose();
                }
            pictureBox1.Image = bmps[0, 0];
            pictureBox2.Image = bmps[0, 1];
            pictureBox3.Image = bmps[0, 2];
            pictureBox4.Image = bmps[0, 3];
            pictureBox5.Image = bmps[1, 0];
            pictureBox6.Image = bmps[1, 1];
            pictureBox7.Image = bmps[1, 2];
            pictureBox8.Image = bmps[1, 3];
            pictureBox9.Image = bmps[2, 0];
            pictureBox10.Image = bmps[2, 1];
            pictureBox11.Image = bmps[2, 2];
            pictureBox12.Image = bmps[2, 3];
            pictureBox13.Image = bmps[3, 0];
            pictureBox14.Image = bmps[3, 1];
            pictureBox15.Image = bmps[3, 2];
            pictureBox16.Image = bmps[3, 3];
        }

解决方案

There's nothing wrong with the code shown here ! Something else is happening that shifts the area of the bitmap copied into each PictureBox right and truncates it.

Check your PictureBoxes to make sure their size is 104,104 and that 'SizeMode is set to 'Normal. Also, check to make sure that the PictureBoxes don't have their 'Anchor or 'Dock property set in such a way that they will re-size if the Form/ContainerControl they are in is re-sized at run-time.


这篇关于将416x416图像分割成16个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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