Create managed image from the unmanaged.

Namespace:  AForge.Imaging
Assembly:  AForge.Imaging (in AForge.Imaging.dll) Version: (


public Bitmap ToManagedImage(
	bool makeCopy


Type: System..::.Boolean
Make a copy of the unmanaged image or not.

Return Value

Returns managed copy of the unmanaged image.


If the makeCopy is set to trueTruetruetrue (True in Visual Basic), then the method creates a managed copy of the unmanaged image, so the managed image stays valid even when the unmanaged image gets disposed. However, setting this parameter to falseFalsefalsefalse (False in Visual Basic) creates a managed image which is just a wrapper around the unmanaged image. So if unmanaged image is disposed, the managed image becomes no longer valid and accessing it will generate an exception.


AForge.Imaging..::.InvalidImagePropertiesExceptionThe unmanaged image has some invalid properties, which results in failure of converting it to managed image. This may happen if user used the UnmanagedImage(IntPtr, Int32, Int32, Int32, PixelFormat) constructor specifying some invalid parameters.

See Also