GraphicsExtensionsToBitmap Method

KGy SOFT Drawing Libraries Help
Copies the Graphics object specified in the graphics parameter to a Bitmap instance.

Namespace:  KGySoft.Drawing
Assembly:  KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 6.0.0

public static Bitmap? ToBitmap(
	this Graphics graphics,
	bool visibleClipOnly


Type: System.DrawingGraphics
The Graphics instance to be converted.
Type: SystemBoolean
When , the result will contain only the area represented by VisibleClipBounds property. When , the result will contain the image of the whole container source (when a container object is found), where the visible clip bounds can be identified by VisibleClipBounds in pixels.

Return Value

Type: Bitmap
A Bitmap object that contains the image content of the source Graphics object, or , when the required area of graphics is empty.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Graphics. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

PlatformNotSupportedExceptionThis method is supported on Windows only.
NotSupportedExceptiongraphics belongs to a Metafile, which cannot be accessed until the graphics is disposed.

Note Note
This method is supported on Windows only.
See Also