Saturday, January 8, 2011

cropping image 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");

No comments:

Post a Comment