Szerkesztés

Megosztás a következőn keresztül:


System.Drawing.Imaging Namespace

Provides advanced GDI+ imaging functionality. Basic graphics functionality is provided by the System.Drawing namespace.

Classes

BitmapData

Specifies the attributes of a bitmap image. The BitmapData class is used by the LockBits and UnlockBits(BitmapData) methods of the Bitmap class. Not inheritable.

CachedBitmap

Represents a device-dependent copy of a Bitmap matching a specified Graphics object's current device (display) settings. Avoids reformatting step when rendering, which can significantly improve performance.

ColorMap

Defines a map for converting colors. Several methods of the ImageAttributes class adjust image colors by using a color-remap table, which is an array of ColorMap structures. Not inheritable.

ColorMatrix

Defines a 5 x 5 matrix that contains the coordinates for the RGBAW space. Several methods of the ImageAttributes class adjust image colors by using a color matrix. This class cannot be inherited.

ColorPalette

Defines an array of colors that make up a color palette. The colors are 32-bit ARGB colors. Not inheritable.

Encoder

An Encoder object encapsulates a globally unique identifier (GUID) that identifies the category of an image encoder parameter.

EncoderParameter

Used to pass a value, or an array of values, to an image encoder.

EncoderParameters

Encapsulates an array of EncoderParameter objects.

FrameDimension

Provides properties that get the frame dimensions of an image. Not inheritable.

ImageAttributes

Contains information about how bitmap and metafile colors are manipulated during rendering.

ImageCodecInfo

The ImageCodecInfo class provides the necessary storage members and methods to retrieve all pertinent information about the installed image encoders and decoders (called codecs). Not inheritable.

ImageFormat

Specifies the file format of the image. Not inheritable.

Metafile

Defines a graphic metafile. A metafile contains records that describe a sequence of graphics operations that can be recorded (constructed) and played back (displayed). This class is not inheritable.

MetafileHeader

Contains attributes of an associated Metafile. Not inheritable.

MetaHeader

Contains information about a windows-format (WMF) metafile.

PropertyItem

Encapsulates a metadata property to be included in an image file. Not inheritable.

WmfPlaceableFileHeader

Defines a placeable metafile. Not inheritable.

Enums

ColorAdjustType

Specifies which GDI+ objects use color adjustment information.

ColorChannelFlag

Specifies individual channels in the CMYK (cyan, magenta, yellow, black) color space. This enumeration is used by the SetOutputChannel methods.

ColorMapType

Specifies the types of color maps.

ColorMatrixFlag

Specifies the types of images and colors that will be affected by the color and grayscale adjustment settings of an ImageAttributes.

ColorMode

Specifies two modes for color component values.

DitherType

Specifies how images are dithered with a reduced color palette.

EmfPlusRecordType

Specifies the methods available for use with a metafile to read and write graphic commands.

EmfType

Specifies the nature of the records that are placed in an Enhanced Metafile (EMF) file. This enumeration is used by several constructors in the Metafile class.

EncoderParameterValueType

Specifies the data type of the EncoderParameter used with the Save or SaveAdd method of an image.

EncoderValue

Used to specify the parameter value passed to a JPEG or TIFF image encoder when using the Save(String, ImageCodecInfo, EncoderParameters) or SaveAdd(EncoderParameters) methods.

ImageCodecFlags

Provides attributes of an image encoder/decoder (codec).

ImageFlags

Specifies the attributes of the pixel data contained in an Image object. The Flags property returns a member of this enumeration.

ImageLockMode

Specifies flags that are passed to the flags parameter of the LockBits method. The LockBits method locks a portion of an image so that you can read or write the pixel data.

MetafileFrameUnit

Specifies the unit of measurement for the rectangle used to size and position a metafile. This is specified during the creation of the Metafile object.

MetafileType

Specifies types of metafiles. The Type property returns a member of this enumeration.

PaletteFlags

Specifies the type of color data in the system palette. The data can be color data with alpha, grayscale data only, or halftone data.

PaletteType

Specifies color palette types.

PixelFormat

Specifies the format of the color data for each pixel in the image.

Delegates

PlayRecordCallback

This delegate is not used. For an example of enumerating the records of a metafile, see EnumerateMetafile(Metafile, Point, Graphics+EnumerateMetafileProc).

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 Metafile class provides methods for recording and saving metafiles. The Encoder class enables users to extend GDI+ to support any image format. The PropertyItem class provides methods for storing and retrieving metadata in image files.

Caution

Classes within the System.Drawing.Imaging namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.

See also