0

i have one pdf file which i will save first as image and then crop that image and save as cropped part as new image. i am not getting any idea how to crop the portion which i want.

here is url how our actual image will look like this

please click on the link and see what value i should provide to extract left rectangle. can you give me any idea.

i got code to crop a portion of image. here is one sample for cropping programmatically.

Rectangle cropRect = new Rectangle(...);
Bitmap src = Image.FromFile(fileName) as Bitmap;
Bitmap target = new Bitmap(cropRect.Width, cropRect.Height);

using(Graphics g = Graphics.FromImage(target))
{
    g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height), 
                cropRect,                        
                GraphicsUnit.Pixel);
}

my concern is what value i should give here to crop the exact left rectangle from the image. Rectangle cropRect = new Rectangle(...);

can anyone give me any idea. thanks i got this code from this url How to crop an image using C#?

thanks

Community
  • 1
  • 1
Thomas
  • 33,544
  • 126
  • 357
  • 626
  • http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing – Thomas Nov 16 '12 at 12:52
  • I might not understand this question. But the cropRect is the part of the original image, you want to cut out. So if your image is 256x256 and you want the lower right part of the image so 1/4, you create a rect x128,y128,w128,h128. – dowhilefor Nov 16 '12 at 12:56

1 Answers1

0

Since these labels are very standard, I wouldn't try to find out what to crop through code. Simply load your picture in a graphics editor which lets you know the coordinates of the mouse cursor (Paint.Net would be a good example) and find your Top, Left, Right and Bottom coordinates. "Hardcode" these values in your program and crop using them.

emartel
  • 7,712
  • 1
  • 30
  • 58