GH_MemoryBitmap

References
public sealed class GH_MemoryBitmap
Utility class for ultra-fast bitmap sampling and filters.

Constructors

GH_MemoryBitmap

#
Constructor with Wrap mode override.
public GH_MemoryBitmap(
Bitmap
bitmap,
Bitmap to operate on. This bitmap will be in an invalid state until the Release() function has been called.
wrap
Wrap mode to use during sampling.
)

GH_MemoryBitmap

#
Default constructor.
public GH_MemoryBitmap(
Bitmap
bitmap
Bitmap to operate on. This bitmap will be in an invalid state until the Release() function has been called.
)

Properties

HasAlphaChannel

#
Gets a value indicating whether or not the local image has an alpha channel defined.
public bool HasAlphaChannel { get; }

Height

#
Gets the height (in pixels) of the local image.
public int Height { get; }

SizeOf

#
Gets the size (in bytes) of the local image.
public int SizeOf { get; }

Width

#
Gets the width (in pixels) of the local image.
public int Width { get; }

Methods

A

#
Gets the alpha channel value at the given pixel coordinates.
public byte A(
x,
X coordinate (column) of pixel. Must be on image interior.
y
Y coordinate (column) of pixel. Must be on image interior.
)
Value of alpha channel at given pixel or 255 if the alpha channel is not defined.

B

#
Gets the blue channel value at the given pixel coordinates.
public byte B(
x,
X coordinate (column) of pixel. Must be on image interior.
y
Y coordinate (column) of pixel. Must be on image interior.
)
Value of Blue channel at given pixel.

Colour

#
Gets the colour at the given pixel coordinates.
public Color Colour(
x,
X coordinate (column) of pixel. Must be on image interior.
y
Y coordinate (column) of pixel. Must be on image interior.
)
Colour at given pixel.

Colour

#
Sets the colour at the given pixel coordinates.
public void Colour(
x,
X coordinate (column) of pixel. Must be on image interior.
y,
Y coordinate (column) of pixel. Must be on image interior.
Color
col
Color to assign.
)

CopyChannel

#
Copy the contents of one channel into another.
public void CopyChannel(
source,
Source channel (compound channels are not allowed).
target
Target channel (compound channels are not allowed).
)

Filter_AlphaEdges

#
Set the alpha component on all edges to a specific value.
public void Filter_AlphaEdges(
padding,
Width of alpha band along all edges. Must be a valid padding construct.
alpha_override
Value of alpha to apply.
)

Filter_Blur

#
Blur the image in both directions.
public void Filter_Blur()

Filter_Blur

#
Blur the image in both directions.
public void Filter_Blur(
interior_weight,
Weighting factor for pixels at the center of the convolution matrix.
exterior_weight
Weighting factor for pixels at the edges of the convolution matrix.
)

Filter_Blur

#
Blur the image N times in both directions.
public void Filter_Blur(
N,
Number of times to perform the blurring operation.
interior_weight,
Weighting factor for pixels at the center of the convolution matrix.
exterior_weight
Weighting factor for pixels at the edges of the convolution matrix.
)

Filter_Blur

#
Blur the image N times in both directions.
public void Filter_Blur(
N
Number of times to perform the blurring operation.
)

Filter_BlurAlpha

#
Blur the alpha channel of the image N times in both directions.
public void Filter_BlurAlpha(
N,
Number of times to perform the blurring operation.
interior_weight,
Weighting factor for pixels at the center of the convolution matrix.
exterior_weight
Weighting factor for pixels at the edges of the convolution matrix.
)

Filter_Contrast

#
Adjust the contrast of a specific channel.
public void Filter_Contrast(
channel,
Channel(s) to modify.
factor
Contrast boost factor. A factor of 1.0 will not affect contrast. Lower values will lessen contrast and higher values will increase contrast.
)

Filter_DitherPattern

#
Create a checkerboard dither pattern.
public void Filter_DitherPattern(
Color
colour
Colour value to set at dithered pixels.
)

Filter_DropShadow

#
Add a drop-shadow to the image. Image is not grown, so if you want the drop shadow to extend beyond the image boundaries, you have to add padding to the image first.
public void Filter_DropShadow(
Size
offset,
Number of pixels (x and y) to offset the drop shadow.
blur,
Amount of blurring for the shadow.
darkness
Darkness factor for the shadow.
)

Filter_Dullify

#
Reduces contrast based on opacity. This filter pulls all colours towards dull grey, without wrecking drop-shadows.
public void Filter_Dullify()

Filter_Equalize

#
Set all the values in a specific channel to a specific value.
public void Filter_Equalize(
channel,
Channel(s) to equalize.
value
Value to equalize with.
)

Filter_GreyScale

#
Convert the image to a greyscale shadow of its former self.
public void Filter_GreyScale()

Filter_GreyScale

#
Convert the image to a greyscale shadow of its former self.
public void Filter_GreyScale(
amount
Greyscale factor. 1.0 equals complete greyscale, 0.0 equals no greyscale, -1.0 equals inverse greyscale
)

Filter_HueScale

#
Convert the image to a greyscale representation of the hues.
public void Filter_HueScale()

Filter_Invert

#
Invert all values in a specific channel.
public void Filter_Invert(
channel
Channel(s) to invert.
)

Filter_LumScale

#
Convert the image to a greyscale representation of the luminance.
public void Filter_LumScale()

Filter_Multiply

#
Multiply all values in a specific channel with a specific factor, using a custom scaling center anchor.
public void Filter_Multiply(
channel,
Channel(s) to multiply.
factor,
Multiplication factor.
anchor
Byte value to scale from.
)

Filter_Multiply

#
Multiply all values in a specific channel with a specific factor.
public void Filter_Multiply(
channel,
Channel(s) to multiply.
factor
Multiplication factor.
)

Filter_SatScale

#
Convert the image to a greyscale representation of the saturation.
public void Filter_SatScale()

Filter_Shift

#
Shift all values in a specific channel with a specific amount.
public void Filter_Shift(
channel,
Channel(s) to shift.
amount
Shift amount.
)

Filter_SpectrumScale

#
Convert the image to a spectral representation of the hues.
public void Filter_SpectrumScale()

Filter_Tint

#
Colorize the image using Hue and Saturation from a base colour.
public void Filter_Tint(
Color
tint,
Colour of colorize operation.
lum_factor,
Luminance blend factor. 0.0 equals no luminance adjustment, 1.0 equals complete luminance adjustment.
sat_factor
Saturation blend factor. 0.0 equals no saturation adjustment, 1.0 equals complete saturation adjustment.
)

Finalize

#
protected override void Finalize()
Object.Finalize

G

#
Gets the greeb channel value at the given pixel coordinates.
public byte G(
x,
X coordinate (column) of pixel. Must be on image interior.
y
Y coordinate (column) of pixel. Must be on image interior.
)
Value of Green channel at given pixel.

OpaqueArea

#
Find the opaque area of a bitmap. The opaque area is the rectangle that contains pixels with a colour that is not fully transparent.
public Rectangle OpaqueArea()
Area of bitmap containing all non-transparent pixels.

PadBitmap

#
Add padding edges around a bitmap.
public static Bitmap PadBitmap(
bmp,
Source bitmap.
padding,
Padding to apply.
Color
padding_color
Color of padded edges.
)
A new bitmap with padded edges and the same PixelFormat as the original bitmap.

R

#
Gets the red channel value at the given pixel coordinates.
public byte R(
x,
X coordinate (column) of pixel. Must be on image interior.
y
Y coordinate (column) of pixel. Must be on image interior.
)
Value of Red channel at given pixel.

Release

#
Release the locked bits. You must call this function when you are done with this GH_MemoryBitmap instance.
public void Release(
includeChanges
If true, changes to the bitmap memory block will be written back into the bitmap.
)

Sample

#
Top level sampling function for interpolated sampling.
public bool Sample(
x,
floating point coordinate in pixel space.
y,
floating point coordinate in pixel space.
ref Color
col
Resulting colour
)

Sample

#
Top level sampling function.
public bool Sample(
x,
Unmapped x pixel coordinate.
y,
Unmapped y pixel coordinate.
ref Color
col
Colour output.
)
True on success, false if pixels could not be sampled.

ShrinkBitmap

#
Shrink an image by removing all outer columns and rows that contain only fully transparent pixels.
public static Bitmap ShrinkBitmap(
Bitmap
image
Image to shrink.
)
Shrunk bitmap.