GraphicsExtensionsToBitmap Method

Copies the Graphics object specified in the graphics parameter to a Bitmap instance.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 8.1.0
C#
public static Bitmap? ToBitmap(
	this Graphics graphics,
	bool visibleClipOnly
)

Parameters

graphics  Graphics
The Graphics instance to be converted.
visibleClipOnly  Boolean
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

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).

Remarks

  Note

This method is supported on Windows only.

Exceptions

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

See Also