Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Download Microsoft Edge
More info about Internet Explorer and Microsoft Edge
Important
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 GDI+ imaging functionality. Basic graphics functionality is provided by the
System.Drawing
namespace.
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
Graphics and Drawing in Windows Forms
Images, Bitmaps, and Metafiles
Working with Images, Bitmaps, Icons, and Metafiles
Using Image Encoders and Decoders in Managed GDI+
Recoloring Images