1

Currently, I'm using a picturebox inside a panel to display images. I have already implemented a logic to move image via mouse cursor.

My question is, if the size of an image is larger than the panel (picturebox's SizeMode=AutoSize), I want to crop and save the part of an image that is visible on the panel. I don't know how to do that. I'm a begginer and I don't have any experience with this.

Arpit
  • 6,212
  • 8
  • 38
  • 69
user1931313
  • 21
  • 1
  • 3

1 Answers1

0

You can use this code to crop image..

private static Image cropImage(Image img, Rectangle cropArea)
{
   Bitmap bmpImage = new Bitmap(img);
   Bitmap bmpCrop = bmpImage.Clone(cropArea,bmpImage.PixelFormat);
   return (Image)(bmpCrop);
}

Also see these tutorial..
http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing
http://jasonjano.wordpress.com/2010/02/13/image-resizing-and-cropping-in-c/

ridoy
  • 6,274
  • 2
  • 29
  • 60
  • thanx..but i want to find the pixel of the panel(X and y axis),i don't know how to do that.. – user1931313 Dec 27 '12 at 09:45
  • See related topic..http://stackoverflow.com/questions/8553794/how-to-get-bitmap-from-painted-panel-in-c-sharp http://stackoverflow.com/questions/476255/access-to-a-single-pixel-in-c-sharp – ridoy Dec 28 '12 at 17:10