Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hallo,
how can I crop an image-file with c#?
Thanks!
Posted

 
Share this answer
 
Comments
Henry Minute 24-Oct-10 17:22pm    
Why on earth would anyone down-vote a perfectly good answer?
Nish Nishant 24-Oct-10 17:37pm    
Well it takes all sorts I guess, even in the QA forum. :-)

Thanks Henry.
C#
public static void Crop(string filename, Rectangle rect)
{
    Bitmap original = new Bitmap(filename);
    Bitmap cropped = original.Clone(rect, PixelFormat.Format32bppArgb);
    original.Dispose();
    cropped.Save(filename);
    cropped.Dispose();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900