C# Class Duality.ExtMethodsBitmap

Provides extension methods for Bitmaps.
Mostrar archivo Open project: BraveSirAndrew/duality

Public Methods

Method Description
Crop ( this bm, bool cropX = true, bool cropY = true ) : Bitmap

Creates a cropped version of the specified Bitmap, removing transparent / empty border areas.

GetAverageColor ( this bm, bool weightTransparent = true ) : ColorRgba

Determines the average color of a Bitmap.

GetPixelDataIntArgb ( this bm ) : int[]

Extracts a Bitmaps pixel data as (signed) IntArgb values.

GetPixelDataRgba ( this bm ) : ColorRgba[]

Extracts a Bitmaps pixel data.

OpaqueBounds ( this bm ) : Rectangle

Measures the bounding rectangle of the opaque pixels in a Bitmap.

Rescale ( this bm, int w, int h, InterpolationMode mode = InterpolationMode.Bilinear ) : Bitmap

Creates a rescaled version of a Bitmap.

Resize ( this bm, int w, int h, Alignment origin = Alignment.TopLeft ) : Bitmap

Creates a resized version of a Bitmap. Gained space will be empty, lost space will crop the image.

SetPixelDataIntArgb ( this bm, int pixelData ) : void

Replaces a Bitmaps pixel data.

SetPixelDataRgba ( this bm, ColorRgba pixelData ) : void

Replaces a Bitmaps pixel data.

SetPixelDataRgba ( this bm, byte pixelData ) : void

Replaces a Bitmaps pixel data.

SubImage ( this bm, System.Drawing.Rect rect ) : Bitmap

Extracts a rectangular portion of the original image.

SubImage ( this bm, Rectangle rect ) : Bitmap

Extracts a rectangular portion of the original image.

SubImage ( this bm, int x, int y, int w, int h ) : Bitmap

Extracts a rectangular portion of the original image.

Method Details

Crop() public static method

Creates a cropped version of the specified Bitmap, removing transparent / empty border areas.
public static Crop ( this bm, bool cropX = true, bool cropY = true ) : Bitmap
bm this The original Bitmap.
cropX bool Whether the image should be cropped in X-direction
cropY bool Whether the image should be cropped in Y-direction
return System.Drawing.Bitmap

GetAverageColor() public static method

Determines the average color of a Bitmap.
public static GetAverageColor ( this bm, bool weightTransparent = true ) : ColorRgba
bm this
weightTransparent bool If true, the alpha value weights a pixels color value.
return ColorRgba

GetPixelDataIntArgb() public static method

Extracts a Bitmaps pixel data as (signed) IntArgb values.
public static GetPixelDataIntArgb ( this bm ) : int[]
bm this
return int[]

GetPixelDataRgba() public static method

Extracts a Bitmaps pixel data.
public static GetPixelDataRgba ( this bm ) : ColorRgba[]
bm this
return ColorRgba[]

OpaqueBounds() public static method

Measures the bounding rectangle of the opaque pixels in a Bitmap.
public static OpaqueBounds ( this bm ) : Rectangle
bm this
return System.Drawing.Rectangle

Rescale() public static method

Creates a rescaled version of a Bitmap.
public static Rescale ( this bm, int w, int h, InterpolationMode mode = InterpolationMode.Bilinear ) : Bitmap
bm this The original Bitmap.
w int The desired width.
h int The desired height.
mode InterpolationMode Specified how to interpolate the original image in order to calculate the result image.
return System.Drawing.Bitmap

Resize() public static method

Creates a resized version of a Bitmap. Gained space will be empty, lost space will crop the image.
public static Resize ( this bm, int w, int h, Alignment origin = Alignment.TopLeft ) : Bitmap
bm this The original Bitmap.
w int The desired width.
h int The desired height.
origin Alignment The desired resize origin in the original image.
return System.Drawing.Bitmap

SetPixelDataIntArgb() public static method

Replaces a Bitmaps pixel data.
public static SetPixelDataIntArgb ( this bm, int pixelData ) : void
bm this
pixelData int
return void

SetPixelDataRgba() public static method

Replaces a Bitmaps pixel data.
public static SetPixelDataRgba ( this bm, ColorRgba pixelData ) : void
bm this
pixelData ColorRgba
return void

SetPixelDataRgba() public static method

Replaces a Bitmaps pixel data.
public static SetPixelDataRgba ( this bm, byte pixelData ) : void
bm this
pixelData byte
return void

SubImage() public static method

Extracts a rectangular portion of the original image.
public static SubImage ( this bm, System.Drawing.Rect rect ) : Bitmap
bm this The original Bitmap.
rect System.Drawing.Rect The rectangular portion to extract.
return System.Drawing.Bitmap

SubImage() public static method

Extracts a rectangular portion of the original image.
public static SubImage ( this bm, Rectangle rect ) : Bitmap
bm this The original Bitmap.
rect System.Drawing.Rectangle The rectangular portion to extract.
return System.Drawing.Bitmap

SubImage() public static method

Extracts a rectangular portion of the original image.
public static SubImage ( this bm, int x, int y, int w, int h ) : Bitmap
bm this The original Bitmap.
x int The rectangular portion to extract.
y int The rectangular portion to extract.
w int The rectangular portion to extract.
h int The rectangular portion to extract.
return System.Drawing.Bitmap