KGySoft.Drawing Namespace

The KGySoft.Drawing namespace contains extension methods and types built around the types of the System.Drawing namespace. Among others, provides advanced support for the Icon type such as extracting, combining and converting multi-resolution icons, including hi-resolution ones, supports saving several Image formats, including formats without built-in encoders (eg. icons and Metafiles), provides methods for pixel format conversion, quantizing, dithering, etc.

Remarks

  Note

Starting with version 7.0.0 the KGySoft.Drawing libraries are split into multiple packages. The Assembly name is indicated for all types, which indicates also the the NuGet package the type is located in.

The available packages of KGy SOFT Drawing Libraries:

KGySoft.Drawing.Core
This package contains the technology and platform independent core functionality and covers most of the types in the KGySoft.Drawing.Imaging namespace along with a few ones in the KGySoft.Drawing namespace. The other packages are dependent on this one.
KGySoft.Drawing
Most types of the KGySoft.Drawing namespace are located in this package. It provides support for many GDI+ types such as Bitmap, Metafile, Icon, Graphics and is dependent on the System.Drawing.Common package, which is supported only on Windows when targeting .NET 7 or later. This package has only one single public class in the KGySoft.Drawing.Imaging namespace, ReadableBitmapDataExtensions, which contains the extension methods that had to be removed from the BitmapDataExtensions class because they use the Bitmap type. Additionally, it defines also a single type converter in the KGySoft.ComponentModel namespace.
KGySoft.Drawing.Wpf
This package provides dedicated support for the System.Windows.Media.Imaging.WriteableBitmap and System.Windows.Media.Imaging.BitmapSource types. Use the WriteableBitmapExtensions.GetReadWriteBitmapData extension method to expose the underlying buffer of a WriteableBitmap of any pixel format as an IReadWriteBitmapData instance to be able to use all of the core operations and transformations for a bitmap data.
KGySoft.Drawing.WinUI
Similarly to the WPF package, this one provides support for the Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap, which is used by Windows App SDK in WinUI applications. It also has a GetReadWriteBitmapData extension method to obtain an IReadWriteBitmapData instance for the bitmap. This package requires targeting at least .NET 5 and Windows 10.0.17763.0 (October 2018 release, version 1809).
KGySoft.Drawing.Uwp
Just like the WinUI package, this one provides support for the Windows.UI.Xaml.Media.Imaging.WriteableBitmap used by the Universal Windows Platform (UWP) platform. Its documentation is not compiled to this combined documentation due to technical reasons but it provides exactly the same functionality as the WinUI package. This package requires targeting at least Windows 10.0.16299.0 (Fall Creators Update, version 1709) so it can reference the .NET Standard 2.0 version of the KGySoft.Drawing.Core library.
KGySoft.Drawing.SkiaSharp
This package provides dedicated support for the SKBitmap, SKPixmap, SKImage and SKSurface types. For example, the SKBitmapExtensions.GetReadWriteBitmapData method can be used to expose the underlying buffer of an SKBitmap as an IReadWriteBitmapData instance to access its pixels directly regardless of its pixel format and color space and to be able to perform all operations on it that are available for an IReadWriteBitmapData instance.

Classes

BitmapExtensions Provides extension methods for the Bitmap type.
CursorHandle Represents a windows cursor that supports colors and partial transparency. The CursorHandle instance can be passed to the System.Windows.Forms.Cursor constructor to create a new cursor.
DrawingCoreModule Represents the KGySoft.Drawing.Core module.
See the Remarks section of the Initialize method for details.
DrawingModule Represents the KGySoft.Drawing module.
See the Remarks section of the Initialize method for details.
GraphicsExtensions Contains extension methods for the Graphics type.
IconExtensions Provides extension methods for the Icon type.
IconInfo Provides information about an Icon image.
Icons Provides some icon-related methods as well as properties returning general icons in multi resolution. Unlike SystemIcons, these icons should be disposed when not used any more.
ImageExtensions Provides extension methods for the Image type.
MetafileExtensions Contains extension methods for the Metafile type.
PixelFormatExtensions Contains extension methods for the PixelFormat type.

Enumerations

ColorChannels Represents the RGB color channels when manipulating images.
DrawingOperation Represents various drawing operations to indicate the current operation when reporting progress using an IAsyncProgress implementation. This library always uses the DrawingOperation type as a type argument when calling the New<T>(T, int, int) method.
ScalingMode Represents the scaling mode when an image needs to be resized.
StockIcon Represents the Windows stock icons can be retrieved by the Icons.GetStockIcon method on Windows Vista and above.
See also the SHSTOCKICONID Enumeration at the Microsoft Docs site.
SystemIconSize Represents the predefined system icon sizes.