I have a picture box of size 492*522.And it's properties are set as below.
BackgroundLayoutImage = Stretch, Sizemode = Stretch Image.
Now I want to display the first half portion of the bitmap in it. With a vertical crop (Y value) of 200. Means 200 should be removed from the top portion of bitmap. I have done it like below.
Rectangle section = new Rectangle(new Point(0, 200), new Size(image.Width / 2, image.Height));
FirstHalf = CropImage(FirstHalf, section);
pictureBox1.Image = FirstHalf;
public Bitmap CropImage(Bitmap source, Rectangle section)
{
var bitmap = new Bitmap(section.Width, section.Height);
using (var g = Graphics.FromImage(bitmap))
{
g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel);
return bitmap;
}
}
But now the size of the picturebox reduces. And it does not give a stretchable look. I want the size of the picture box to 492*522 itself. And should get a stretchable look when cropping 200 from bitmap. How can I achieve this? Please help.