The following code clips a portion of image of size width=100 and height=100. It displays a clipped portion in another picture box. To run this code, place two picture boxes in a form and set the image for the first picturebox.
Bitmap ReqdBmp = new Bitmap(100, 100); Graphics Gra = pictureBox1.CreateGraphics(); Graphics g2 = pictureBox2.CreateGraphics(); g2.DrawImage(pictureBox1.Image, new Rectangle(0, 0, ReqdBmp.Width, ReqdBmp.Height), new Rectangle(100, 100, ReqdBmp.Width, ReqdBmp.Height), GraphicsUnit.Pixel);
|
| Author: Neeraj Saluja 12 May 2008 | Member Level: Gold Points : 2 |
The code is not appearing completely. It should be
Bitmap ReqdBmp = new Bitmap(100, 100); Graphics Gra = pictureBox1.CreateGraphics(); Graphics g2 = pictureBox2.CreateGraphics(); g2.DrawImage(pictureBox1.Image, new Rectangle(0, 0, ReqdBmp.Width, ReqdBmp.Height), new Rectangle(100, 100, ReqdBmp.Width, ReqdBmp.Height), GraphicsUnit.Pixel);
|
| Author: Balamurali Balaji 12 May 2008 | Member Level: Diamond Points : 2 |
Thank you.
|