ערוך

שתף באמצעות


System.Drawing Namespace

Provides access to GDI+ basic graphics functionality. The System.Drawing.Drawing2D, System.Drawing.Imaging, and System.Drawing.Text namespaces provide more advanced functionality. For limitations, see the Remarks section.

Classes

Bitmap

Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes. A Bitmap is an object used to work with images defined by pixel data.

BitmapSuffixInSameAssemblyAttribute

Specifies that, when interpreting ToolboxBitmapAttribute declarations, the assembly should look for the indicated resources in the same assembly, but with the BitmapSuffix configuration value appended to the declared file name.

BitmapSuffixInSatelliteAssemblyAttribute

Specifies that, when interpreting ToolboxBitmapAttribute declarations, the assembly should look for the indicated resources in a satellite assembly, but with the BitmapSuffix configuration value appended to the declared file name.

Brush

Defines objects used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths.

Brushes

Brushes for all the standard colors. This class cannot be inherited.

BufferedGraphics

Provides a graphics buffer for double buffering.

BufferedGraphicsContext

Provides methods for creating graphics buffers that can be used for double buffering.

BufferedGraphicsManager

Provides access to the main buffered graphics context object for the application domain.

ColorConverter

Converts colors from one data type to another. Access this class through the TypeDescriptor.

ColorTranslator

Translates colors to and from GDI+ Color structures. This class cannot be inherited.

Font

Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.

FontConverter

Converts Font objects from one data type to another.

FontConverter.FontNameConverter

FontConverter.FontNameConverter is a type converter that is used to convert a font name to and from various other representations.

FontConverter.FontUnitConverter

Converts font units to and from other unit types.

FontFamily

Defines a group of type faces having a similar basic design and certain variations in styles. This class cannot be inherited.

Graphics

Encapsulates a GDI+ drawing surface. This class cannot be inherited.

Icon

Represents a Windows icon, which is a small bitmap image that is used to represent an object. Icons can be thought of as transparent bitmaps, although their size is determined by the system.

IconConverter

Converts an Icon object from one data type to another. Access this class through the TypeDescriptor object.

Image

An abstract base class that provides functionality for the Bitmap and Metafile descended classes.

ImageAnimator

Animates an image that has time-based frames.

ImageConverter

ImageConverter is a class that can be used to convert Image objects from one data type to another. Access this class through the TypeDescriptor object.

ImageFormatConverter

ImageFormatConverter is a class that can be used to convert ImageFormat objects from one data type to another. Access this class through the TypeDescriptor object.

Pen

Defines an object used to draw lines and curves. This class cannot be inherited.

Pens

Pens for all the standard colors. This class cannot be inherited.

PointConverter

Converts a Point object from one data type to another.

RectangleConverter

Converts rectangles from one data type to another. Access this class through the TypeDescriptor.

Region

Describes the interior of a graphics shape composed of rectangles and paths. This class cannot be inherited.

SizeConverter

The SizeConverter class is used to convert from one data type to another. Access this class through the TypeDescriptor object.

SizeFConverter

Converts SizeF objects from one type to another.

SolidBrush

Defines a brush of a single color. Brushes are used to fill graphics shapes, such as rectangles, ellipses, pies, polygons, and paths. This class cannot be inherited.

StringFormat

Encapsulates text layout information (such as alignment, orientation and tab stops) display manipulations (such as ellipsis insertion and national digit substitution) and OpenType features. This class cannot be inherited.

SystemBrushes

Each property of the SystemBrushes class is a SolidBrush that is the color of a Windows display element.

SystemColors

Each property of the SystemColors class is a Color structure that is the color of a Windows display element.

SystemFonts

Specifies the fonts used to display text in Windows display elements.

SystemIcons

Each property of the SystemIcons class is an Icon object for Windows system-wide icons. This class cannot be inherited.

SystemPens

Each property of the SystemPens class is a Pen that is the color of a Windows display element and that has a width of 1 pixel.

TextureBrush

Each property of the TextureBrush class is a Brush object that uses an image to fill the interior of a shape. This class cannot be inherited.

ToolboxBitmapAttribute

Allows you to specify an icon to represent a control in a container, such as the Microsoft Visual Studio Form Designer.

Structs

CharacterRange

Specifies a range of character positions within a string.

Color

Represents an ARGB (alpha, red, green, blue) color.

Point

Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional plane.

PointF

Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimensional plane.

Rectangle

Stores a set of four integers that represent the location and size of a rectangle.

RectangleF

Stores a set of four floating-point numbers that represent the location and size of a rectangle. For more advanced region functions, use a Region object.

Size

Stores an ordered pair of integers, which specify a Height and Width.

SizeF

Stores an ordered pair of floating-point numbers, typically the width and height of a rectangle.

Interfaces

IDeviceContext

Defines methods for obtaining and releasing an existing handle to a Windows device context.

Enums

ContentAlignment

Specifies alignment of content on the drawing surface.

CopyPixelOperation

Determines how the source color in a copy pixel operation is combined with the destination color to result in a final color.

FontStyle

Specifies style information applied to text.

GraphicsUnit

Specifies the unit of measure for the given data.

KnownColor

Specifies the known system colors.

RotateFlipType

Specifies how much an image is rotated and the axis used to flip the image.

StockIconId

Provides icon identifiers for use with GetStockIcon(StockIconId, StockIconOptions).

StockIconOptions

Provides options for use with GetStockIcon(StockIconId, StockIconOptions).

StringAlignment

Specifies the alignment of a text string relative to its layout rectangle.

StringDigitSubstitute

The StringDigitSubstitute enumeration specifies how to substitute digits in a string according to a user's locale or language.

StringFormatFlags

Specifies the display and layout information for text strings.

StringTrimming

Specifies how to trim characters from a string that does not completely fit into a layout shape.

StringUnit

Specifies the units of measure for a text string.

Delegates

Graphics.DrawImageAbort

Provides a callback method for deciding when the DrawImage method should prematurely cancel execution and stop drawing an image.

Graphics.EnumerateMetafileProc

Provides a callback method for the EnumerateMetafile method.

Image.GetThumbnailImageAbort

Provides a callback method for determining when the GetThumbnailImage(Int32, Int32, Image+GetThumbnailImageAbort, IntPtr) method should prematurely cancel execution.

Remarks

Caution

The System.Drawing namespace has some limitations for certain operating systems and application types.

  • On Windows, System.Drawing depends 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.Drawing namespace 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.

  • In .NET 6 and later versions, the System.Drawing.Common NuGet package is only supported on Windows operating systems. For more information, see System.Drawing.Common only supported on Windows.

If you can't use System.Drawing with your application, recommended alternatives include ImageSharp, SkiaSharp, Windows Imaging Components, and Microsoft.Maui.Graphics.

The Graphics class provides methods for drawing to the display device. Classes such as Rectangle and Point encapsulate GDI+ primitives. The Pen class is used to draw lines and curves, while classes derived from the abstract class Brush are used to fill the interiors of shapes.