Cut an image every 300 pixels high

Asked

Viewed 656 times

1

I’m developing a clipping report generator where I need to insert images captured from web pages. Most of the time it is necessary to cut them and to distribute them on the PDF pages. How do I programmatically crop an image every 300 pixels high?

NOTE: It can be in VB or C# the answer.

  • 2

    Add to your question what you tried, and be less comprehensive on the issue. If you haven’t tried anything, Google is a good start.

1 answer

2


You can make a cut in the bitmap and then make the conversion.

public Bitmap CropBitmap(Bitmap bitmap, int cropX, int cropY, int cropWidth, int cropHeight){
    Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);
    Bitmap cropped = bitmap.Clone(rect, bitmap.PixelFormat);
    return cropped;
}
  • Thanks, I just needed to pass this method inside a FOR loop until the end of the image.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.