cropping image in c#

By Super Man

here i will show you how to crop image at run time in c#

here i will create one bitmap from the image.
and using clone method i am getting(crop) the cropped image.

code snippet :


           Image img = Image.FromFile("c:\\hello.jpg");
           Bitmap bmpImage = new Bitmap(img);
           Bitmap bmpCrop = bmpImage.Clone(new Rectangle(100, 100, 300, 300), bmpImage.
           PixelFormat);

             bmpCrop.Save("c:\\hellocrop.jpg");

cropping image in c#  (1659 Views)