Drawing. Drawing2D Namespace
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides advanced two-dimensional and vector graphics functionality.
Represents an adjustable arrow-shaped line cap. This class cannot be inherited.
Defines a blend pattern for a LinearGradientBrush object. This class cannot be inherited.
Defines arrays of colors and positions used for interpolating color blending in a multicolor gradient. This class cannot be inherited.
Encapsulates a custom user-defined line cap.
Represents the internal data of a graphics container. This class is used when saving the state of a Graphics object using the BeginContainer() and EndContainer(GraphicsContainer) methods. This class cannot be inherited.
Represents a series of connected lines and curves. This class cannot be inherited.
Provides the ability to iterate through subpaths in a GraphicsPath and test the types of shapes contained in each subpath. This class cannot be inherited.
Defines a rectangular brush with a hatch style, a foreground color, and a background color. This class cannot be inherited.
Encapsulates a Brush with a linear gradient. This class cannot be inherited.
Encapsulates a 3-by-3 affine matrix that represents a geometric transform. This class cannot be inherited.
Contains the graphical data that makes up a GraphicsPath object. This class cannot be inherited.
Encapsulates the data that makes up a Region object. This class cannot be inherited.
Specifies how different clipping regions can be combined.
Specifies how the source colors are combined with the background colors.
Specifies the quality level to use during compositing.
Specifies the system to use when evaluating coordinates.
Specifies the type of graphic shape to use on both ends of each dash in a dashed line.
Specifies the style of dashed lines drawn with a Pen object.
Specifies how the interior of a closed path is filled.
Specifies whether commands in the graphics stack are terminated (flushed) immediately or executed as soon as possible.
Specifies the different patterns available for HatchBrush objects.
The InterpolationMode enumeration specifies the algorithm that is used when images are scaled or rotated.
Specifies the direction of a linear gradient.
Specifies the available cap styles with which a Pen object can end a line.
Specifies how to join consecutive line or curve segments in a figure (subpath) contained in a GraphicsPath object.
Specifies the order for matrix transform operations.
Specifies the type of point in a GraphicsPath object.
Specifies the alignment of a Pen object in relation to the theoretical, zero-width line.
Specifies the type of fill a Pen object uses to fill lines.
Specifies how pixels are offset during rendering.
Specifies the overall quality when rendering GDI+ objects.
Specifies whether smoothing (antialiasing) is applied to lines and curves and the edges of filled areas.
Specifies the type of warp transformation applied in a Warp method.
Specifies how a texture or gradient is tiled when it is smaller than the area being filled.
System.Drawing namespace has some limitations for certain operating systems and application types.
System.Drawingdepends on the GDI+ native library, which is shipped as part of the OS. Some Windows SKUs, like Windows Server Core or Windows Nano, don't include this native library as part of the OS. If you use this namespace and the library can't be loaded, exceptions will be thrown at run time.
Some types in the
System.Drawingnamespace rely on GDI+, which is not supported in Windows services and ASP.NET Core and ASP.NET apps. These types are in the System.Drawing.Common NuGet package and include System.Drawing.Bitmap and System.Drawing.Font. However, primitive types in the namespace, such as System.Drawing.Color, System.Drawing.Size, System.Drawing.Point, and System.Drawing.Rectangle, can be used in any application.
In .NET 5 and previous versions, the System.Drawing.Common NuGet package works on Windows, Linux, and macOS. However, there are some platform differences. On Linux and macOS, the GDI+ functionality is implemented by the libgdiplus) library. This library is not installed by default in most Linux distributions and doesn't support all the functionality of GDI+ on Windows and macOS. There are also platforms where libgdiplus is not available at all. To use types from the System.Drawing.Common package on Linux and macOS, you must install libgdiplus separately. For more information, see Install .NET on Linux or Install .NET on macOS.
The following table lists some of the important classes and enumerations in the System.Drawing.Drawing2D namespace, grouped into categories.
|- Graphics and Graphics paths||The GraphicsState and GraphicsContainer classes report information about the current
|- Matrix and transformation related types||The Matrix class represents a matrix for geometric transforms. The MatrixOrder enumeration specifies the order for matrix transformations.|
|- Brush classes||The PathGradientBrush and HatchBrush classes enable you to fill shapes with either a gradient, or hatch pattern, respectively.|
|- Enumeration related to lines||The LineCap and CustomLineCap enumerations enable you to specify cap styles for a line. The, LineJoin enumeration enables you to specify how two lines are joined in a path. The PenAlignment enumeration enables you specify the alignment of the drawing tip, when you draw a line. The PenType enumeration specifies the pattern a line should be filled with.|
|- Enumerations related to filling shapes and paths||The HatchStyle enumeration specifies fill styles for a HatchBrush. The Blend class specifies a blend pattern for a LinearGradientBrush. The FillMode enumeration specifies the fill style for a GraphicsPath.|
Classes in the System.Drawing.Drawing2D namespace are not supported for use in a Windows or ASP.NET service. Attempting to use these classes in one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.