BitmapExtensionMethods
Extension methods for Eto.Drawing.Bitmap
Methods
Add a constant to all values in HSL channels.
Add a constant to all channel values.
Apply a custom filter delegate to a bitmap.
public static void ApplyFilterDelegate()
Blur an image.
Apply a custom blurring curve.
public static void Blur()
this BitmapData
data,
Bitmap data to operate on.
float[]
xProfile,
Array of horizontal weighting factors. The first value equals the weight at the pixel itself, with every additional value indicating the weight of the next pixel. The length of the array thus specified the horizontal blurring radius.
float[]
yProfile,
Array of vertical weighting factors. The first value equals the weight at the pixel itself, with every additional value indicating the weight of the next pixel. The length of the array thus specified the vertical blurring radius.
iterations
Number of blurring iterations to run.
Clear the entire image using a checkerboard pattern.
public static void ClearCheckerBoard()
this BitmapData
data,
Bitmap data accessor.
Color
a,
First colour.
Color
b,
Second colour.
size
Square size.
Apply colour to half the pixels in an image using a checkerboard pattern.
public static void ClearCheckerBoard()
Set all pixels within a rectangle to a specific colour.
public static void ClearRectangle()
this BitmapData
data,
Bitmap to adjust.
Rectangle
rectangle,
Rectangle.
Color
color
Color to assign to all pixels within rectangle.
Create a custom sized palette containing the most relevant colours in a bitmap.
public static Color[] CreatePalette()
this Bitmap
bitmap,
Bitmap to sample.
count,
Number of colours in palette. May not exceed 2^12 = 4096.
accuracy,
Pixel accuracy between samples.
mean,
Mean computation algorithm.
alpha
If true, alpha values will be included in the palette.
Returns: Array of colour representing the N most relevant colours in the bitmap.
Create a custom sized palette containing the most relevant colours in a bitmap.
public static Color[] CreatePalette()
this BitmapData
data,
Bitmap to sample.
count,
Number of colours in palette. May not exceed 2^12 = 4096.
accuracy,
Pixel accuracy between samples.
mean,
Mean computation algorithm.
alpha
If true, alpha values will be included in the palette.
Returns: Array of colour representing the N most relevant colours in the bitmap.
Dither an image using a palette.
public static void Dither()
this BitmapData
data,
Bitmap to dither.
palette,
Collection of colours in palette.
algorithm
Dither algorithm to use.
Dither an image using a palette.
public static void Dither()
this BitmapData
data,
Bitmap to dither.
palette,
Palette stored as spatial tree.
algorithm
Dither algorithm to use.
Draw an arc gradient into a rectangle.
Draw a circular gradient into a rectangle.
Draw an expression evaluated gradient into a rectangle.
public static void DrawExpressionGradient()
this BitmapData
data,
Bitmap to draw onto.
Rectangle
rectangle,
Rectangle to fill.
gradient,
Gradient.
expression
Expression to evaluate. Expression must take x and y variables and resolve to a number.
Draw a linear gradient into a rectangle.
public static void DrawLinearGradient()
this BitmapData
data,
Bitmap to draw onto.
Rectangle
rectangle,
Rectangle to fill.
gradient,
Gradient.
PointF
point0,
Start point of gradient.
PointF
point1
End point of gradient.
Draw a radial gradient into a rectangle.
Draw a rectangle gradient into a rectangle.
public static void DrawRectangleGradient()
this BitmapData
data,
Bitmap to draw onto.
Rectangle
rectangle,
Rectangle to fill.
gradient,
Gradient.
RectangleF
box,
Gradient base rectangle.
distance0,
Distance from rectangle where gradient starts.
distance1
Distance from rectangle where gradient ends.
Draw an expression evaluated gradient into a rectangle.
public static void DrawSimplexNoiseGradient()
this BitmapData
data,
Bitmap to draw onto.
Rectangle
rectangle,
Rectangle to fill.
gradient
Gradient.
Create a fading and blurring drop shadow directly downwards.
public static void DropShadow()
this BitmapData
data,
Locked bitmap data.
style,
Shadow styling.
darkness = 0.35,
Shadow darkness directly underneath opaque pixels.
decay = 0.95,
Transparency decay as shadow moves downwards.
bottomFade = true
If true, the shadow fades near the bottom of the image.
Duplicate all pixels on the edges rectangle outwards.
public static void DuplicateEdgePixels()
this BitmapData
data,
Bitmap data to modify.
Rectangle
edges
Edges rectangle. Must be fully within the bitmap bounds.
Enlarge a bitmap with integral factors.
Returns: Enlarged bitmap.
Linearly increase the transparency of the edges of the image.
public static void FadeEdges()
this BitmapData
data,
Bitmap locked bytes.
left,
Number of pixel columns along the left edge for fading.
top,
Number of pixel rows along the top edge for fading.
right,
Number of pixel columns along the right edge for fading.
bottom
Number of pixel rows along the bottom edge for fading.
Multiply all the alpha values with a specific constant.
public static void FadeTransparent()
Fill the inside of a closed shape with a specific colour.
public static void FillShape()
this BitmapData
bitmap,
Bitmap data to modify.
shapes,
Shapes to fill.
Color
fill,
Fill colour.
invert,
Invert inside/outside metric.
edge,
Round edge thickness.
contrast
Contrast.
Fill the inside of a closed shape with a specific colour.
public static void FillShape()
this BitmapData
bitmap,
Bitmap data to modify.
shapes,
Shapes to fill.
Color
fill,
Fill colour.
invert
Invert inside/outside metric.
Replace all pixels around the edges of the bitmap with the nearest colour on the interior.
Copy the contents of a colour buffer back into a bitmap.
Copy the entire contents of a colour buffer back into a bitmap.
public static void FromColorArray()
this BitmapData
data,
Bitmap to copy into.
Color[][]
buffer
Colour buffer.
LoadImageFromColourAndAlphaFiles
#Load an image from a colour file and an alpha file.
Turn a bitmap into a greyscale represention of itself.
public static void MakeGreyScale()
this BitmapData
data,
Bitmap to modify.
metric,
Luminance metric to use.
retainAlpha,
If true, alpha values are maintained.
gradient
Gradient for luminance mapping. Gradient should be well defined between 0.0 and 1.0.
Turn a bitmap into a greyscale represention of itself.
public static void MakeGreyScale()
this BitmapData
data,
Bitmap to modify.
metric,
Luminance metric to use.
retainAlpha
If true, alpha values are maintained.
Set all the alpha values to a specific constant.
Multiply all values in a specific channel by a factor.
Multiply all values in a specific channel by a factor.
Overlay an image on top of this image.
public static void Overlay()
this BitmapData
target,
Target image.
BitmapData
source,
Overlay image.
position,
Position of overlay.
Overlay
overlay
Overlay filter.
Pad all edges of a bitmap by a specific count.
public static Bitmap PadEdges()
this Bitmap
bitmap,
Bitmap to pad.
count,
Number of pixels to add to all edges.
Color
colour
Padding colour.
Returns: Padded bitmap.
Pad all edges of a bitmap by a specific count.
public static Bitmap PadEdges()
Returns: Padded bitmap.
Pad all edges of a bitmap by a specific count.
public static Bitmap PadEdges()
this Bitmap
bitmap,
Bitmap to pad.
Padding
padding,
Padding dimensions.
Color
colour
Padding colour.
Returns: Padded bitmap.
Pad all edges of a bitmap by a specific count.
public static Bitmap PadEdges()
this Bitmap
bitmap,
Bitmap to pad.
Padding
padding
Padding dimensions.
Returns: Padded bitmap.
Map the distances from each pixel to an existing palette.
public static void PaletteDeviation()
this BitmapData
data,
Image data.
palette,
Palette.
mapping,
Colour mapping.
gradient
Gradient to apply (0.0 = exact match, 1.0=furthest possible distance).
Map the distances from each pixel to an existing palette.
public static void PaletteDeviation()
this BitmapData
data,
Image data.
palette,
Palette.
gradient
Gradient to apply (0.0 = exact match, 1.0=furthest possible distance).
Place another bitmap into this bitmap.
public static void Place()
this BitmapData
target,
Bitmap to insert into.
BitmapData
source,
Bitmap to insert.
position
Position (upper left pixel) of placed bitmap.
PrintScreenArea
#Gets a custom sized portion of the screen underneath the cursor. The cursor location is in the middle.
public static Bitmap PrintScreenArea()
PointF
centre,
Size
size
Returns: Bitmap under cursor.
Bitmap save process which automatically picks the correct file format.
SaveImageToColourAndAlphaFiles
#Save a bitmap as a separate colour file and a separate alpha channel file. This is basically used to create jpeg sized images with alpha channels.
Highlight a specific channel. This is primarily a UI filter, showing the user the salient properties of a specific channel.
public static void ShowCaseChannel()
Highlight the luminance channel using a specific metric. This is primarily a UI filter, showing the user the salient properties of a specific channel.
public static void ShowCaseChannel()
Stack a bunch of bitmaps horizontally.
public static Bitmap StackHorizontal()
this Bitmap
bitmap,
First bitmap.
params Bitmap[]
tiles
Additional bitmaps to stack.
Returns: Stacked bitmap.
Stack a bunch of bitmaps vertically.
public static Bitmap StackVertical()
this Bitmap
bitmap,
First bitmap.
params Bitmap[]
tiles
Additional bitmaps to stack.
Returns: Stacked bitmap.
Streak an image.
public static void Streak()
this BitmapData
data,
Bitmap to streak.
direction,
Streaking direction.
offset
Streak source offset.
Convert a bitmap into a jagged colour array.
public static Color[][] ToColorArray()
this BitmapData
data
Bitmap to convert.
Returns: Jagged array of colours. Each nested array represents a column in the original bitmap.
Create a sampling set of all the colours in a bitmap.
Returns: Sampling set.
Create a sampling set of all the colours in a bitmap.
Returns: Sampling set.
Convert a bitmap to a cursor.
public static Cursor ToCursor()
this Bitmap
bitmap,
Bitmap to use. Should be square.
targetSize,
Target size (width and height in pixels).
PointF
hotspot
Hotspot coordinate within [targetSize,targetSize] box.
Cut out a portion of a bitmap.
Returns: Trimmed bitmap.
Create a new bitmap which trims all edges if they consist of a solid colour.
public static Bitmap TrimEdges()
this Bitmap
bitmap,
Bitmap to trim.
Color
trimColour,
Colour to cut away.
leaveColumns = 0
Number of columns to leave intact anyway.
Returns: Trimmed bitmap, or the same bitmap if no trimming was possible.