locked
how to croop and save image??? RRS feed

  • Question

  • how to croop and save image at other image???

    Sunday, September 21, 2014 5:33 PM

Answers

  • Hi,

    use the overload of Bitmap.Clone() that uses a Rectangle and the PixelFormat as parameters to crop.

    Use Bitmap.Save to save.

    Regards,

      Thorsten

    • Marked as answer by adi khan Tuesday, September 23, 2014 10:29 AM
    Sunday, September 21, 2014 5:47 PM
  • ... basically:

                Bitmap bmp = new Bitmap(@"Put\here\path\to\image");
                Bitmap bmpCropped = bmp.Clone(new Rectangle(0, 0, 200, 200), bmp.PixelFormat);
                bmpCropped.Save(@"Put\save\path\here", System.Drawing.Imaging.ImageFormat.Png);

    Regards,

      Thorsten

    • Proposed as answer by Kristin Xie Tuesday, September 23, 2014 8:17 AM
    • Marked as answer by adi khan Tuesday, September 23, 2014 10:29 AM
    Sunday, September 21, 2014 5:49 PM

All replies

  • Sunday, September 21, 2014 5:45 PM
  • Hi,

    use the overload of Bitmap.Clone() that uses a Rectangle and the PixelFormat as parameters to crop.

    Use Bitmap.Save to save.

    Regards,

      Thorsten

    • Marked as answer by adi khan Tuesday, September 23, 2014 10:29 AM
    Sunday, September 21, 2014 5:47 PM
  • ... basically:

                Bitmap bmp = new Bitmap(@"Put\here\path\to\image");
                Bitmap bmpCropped = bmp.Clone(new Rectangle(0, 0, 200, 200), bmp.PixelFormat);
                bmpCropped.Save(@"Put\save\path\here", System.Drawing.Imaging.ImageFormat.Png);

    Regards,

      Thorsten

    • Proposed as answer by Kristin Xie Tuesday, September 23, 2014 8:17 AM
    • Marked as answer by adi khan Tuesday, September 23, 2014 10:29 AM
    Sunday, September 21, 2014 5:49 PM
  • thnkx

    Tuesday, September 23, 2014 10:25 AM
  • thnkx

    Tuesday, September 23, 2014 10:25 AM