Extract sub image from image using C #

I have a Bitmap object from this, do I need to extract a helper image and save it as a Bitmap object, passing in a Rectangle object that contains the coordinates of the subframe?

Is there a C # library that can do this, or can Aforge extract from a sub-image.

thanks

+7
source share
1 answer

The bitmap class has a Clone method that directly accepts the target rectangle.

Since you are already working with Bitmap , calling Clone with your rectangle and the desired PixelFormat (which may be originalBitmap.PixelFormat ) should provide you with what you need, without any additional dependencies.

 Bitmap croppedImage = originalBitmap.Clone(theRect, originalBitmap.PixelFormat); 
+17
source

All Articles