I am currently trying to crop the image and then save the new image. I have the original image, the x and y coordinates, where on this image I want the crop to be, and the width and height of the new cropped image.
Here is my code:
Bitmap originalBitmap = new Bitmap(filePath);
Bitmap newImage = new Bitmap(width, height);
Graphics g = Graphics.FromImage(newImage);
g.DrawImage(originalBitmap, x, y, width, height);
newImage.Save(newFilePath);
But when the image is saved, this is a small image of the correct height and width, but completely empty.
I'm sure I'm just missing the trick here or completely misunderstanding something (or both!), So any help will be appreciated!
source
share