BitmapExtensions Class

Provides extension methods for the Bitmap type.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 8.1.0
C#
public static class BitmapExtensions
Inheritance
Object    BitmapExtensions

Methods

AdjustBrightness Adjusts the brightness of the specified bitmap.
AdjustContrast Adjusts the contrast of the specified bitmap.
AdjustGamma Adjusts the gamma correction of the specified bitmap.
Clear(Bitmap, Color, Color, Byte) Clears the complete bitmap and fills it with the specified color.
This method is similar to Graphics.Clear but can be used for Bitmaps of any PixelFormat.
Clear(Bitmap, Color, IDitherer, Color, Byte) Clears the complete bitmap and fills it with the specified color.
This method is similar to Graphics.Clear but can be used for Bitmaps of any PixelFormat.
CloneCurrentFrame Creates a clone of the current frame of the provided Bitmap instance. Unlike the Bitmap(Image) constructor, this method attempts to preserve original pixel format, and unlike Bitmap.Clone(Rectangle,PixelFormat) method, this method returns a single frame image.
Dither Quantizes a bitmap with dithering (reduces the number of colors while trying to preserve details) using the specified quantizer and ditherer.
ExtractBitmaps When image contains multiple pages, frames or multi-resolution sub-images, returns them as separated Bitmap instances. Otherwise, returns a new Bitmap with the copy of the original image.
GetColorCount Gets the actual number of colors of the specified bitmap. Colors are counted even for indexed bitmaps.
GetColors Gets the colors used in the defined bitmap. A limit can be defined in maxColors.
GetReadableBitmapData(Bitmap, Color, Byte) Gets an IReadableBitmapData instance, which provides fast read-only access to the actual data of the specified bitmap. The bitmap can have any PixelFormat.
See the Remarks section of the GetReadWriteBitmapData method for details and examples.
GetReadableBitmapData(Bitmap, WorkingColorSpace, Color, Byte) Gets an IReadableBitmapData instance, which provides fast read-only access to the actual data of the specified bitmap. The bitmap can have any PixelFormat.
See the Remarks section of the GetReadWriteBitmapData method for details and examples.
GetReadWriteBitmapData(Bitmap, Color, Byte) Gets an IReadWriteBitmapData instance, which provides fast read-write access to the actual data of the specified bitmap. The bitmap can have any PixelFormat.
See the Remarks section of the GetReadWriteBitmapData(Bitmap, WorkingColorSpace, Color, Byte) overload for details.
GetReadWriteBitmapData(Bitmap, WorkingColorSpace, Color, Byte) Gets an IReadWriteBitmapData instance, which provides fast read-write access to the actual data of the specified bitmap. The bitmap can have any PixelFormat.
GetWritableBitmapData(Bitmap, Color, Byte) Gets an IWritableBitmapData instance, which provides fast write-only access to the actual data of the specified bitmap. The bitmap can have any PixelFormat.
See the Remarks section of the GetReadWriteBitmapData method for details and examples.
GetWritableBitmapData(Bitmap, WorkingColorSpace, Color, Byte) Gets an IWritableBitmapData instance, which provides fast write-only access to the actual data of the specified bitmap. The bitmap can have any PixelFormat.
See the Remarks section of the GetReadWriteBitmapData method for details and examples.
Invert Inverts the colors of the specified bitmap.
MakeGrayscale Makes a bitmap grayscale.
MakeOpaque Makes a bitmap opaque using the specified backColor.
Quantize Quantizes a bitmap using the specified quantizer (reduces the number of colors).
ReplaceColor Replaces every oldColor occurrences to newColor in the specified bitmap.
Resize(Bitmap, Size, Boolean) Resizes the image with high quality. The result always has a Format32bppPArgb pixel format.
This overload uses Graphics.DrawImage internally, which provides a good quality result but on Windows blocks every parallel DrawImage call within the same process. If that might be an issue use the Resize(Bitmap, Size, ScalingMode, Boolean) overload instead.
Resize(Bitmap, Size, ScalingMode, Boolean) Resizes the image using the specified scalingMode. The result always has a Format32bppPArgb pixel format.
ToCursorHandle Converts the provided bitmap to a CursorHandle, which can be passed to the System.Windows.Forms.Cursor constructor to create a new cursor that supports colors and partial transparency.
TransformColors(Bitmap, FuncColor32, Color32, Color, Byte) Transforms the colors of a bitmap using the specified transformFunction delegate.
TransformColors(Bitmap, FuncColor32, Color32, IDitherer, Color, Byte) Transforms the colors of a bitmap using the specified transformFunction delegate.

See Also