Lets say I want to click on an image and enlarge the part above where I clicked. I do that with the simplest code, but at the bottom of the image there is an annoying edge because of the enlargement.
There is no Graphics
involved, so I can't use SetWrapMode(WrapMode.TileFlipXY);
or graphic.CompositingMode = CompositingMode.SourceCopy;
I can crop the annoying edge part (its not important) but I don't know what is its height.
How can I know what is its height so I can crop it? Better yet - is there a better method to enlarge the image (I need a method that returns a bitmap so I can save it later)?
The simple code:
private void button1_Click(object sender, EventArgs e)
{
try
{
Bitmap img = new Bitmap(imageLoc);
Rectangle cropArea = new Rectangle(0, 0, img.Width, yLoc);
Bitmap bmpImage = new Bitmap(img);
Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
pictureBox1.Image = resizeImage(bmpCrop, new Size(bmpCrop.Width, newHeight));
}
catch
{
}
}
public static Bitmap resizeImage(Image imgToResize, Size size)
{
return new Bitmap(imgToResize, size);
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
xLoc = e.X;
yLoc = e.Y;
}
The annoying edge (look at the bottom):