9

I have a Bitmap object from this I need to extract a sub image and keep it as a Bitmap object by passing Rectangle object which contains sub image co-ordinates?

Is there a c# library which is able to do this or is Aforge able to extract sub image.

Thanks

4

1 回答 1

26

Bitmap 类有一个直接接受目标矩形的Clone方法。

由于您已经在使用 a ,因此使用您的矩形和期望(可能是)Bitmap调用应该可以满足您的需求,而无需其他依赖项。ClonePixelFormatoriginalBitmap.PixelFormat

Bitmap croppedImage = originalBitmap.Clone(theRect, originalBitmap.PixelFormat);
于 2012-07-12T17:56:43.140 回答