Class ImageSharpExtensions
Inheritance
ImageSharpExtensions
Assembly: Acoustics.Shared.dll
Syntax
public static class ImageSharpExtensions
Fields
|
Improve this Doc
View Source
ColorRegExError
Declaration
public const string ColorRegExError = "Must adhere to a standard hex color code (#00000000)"
Field Value
|
Improve this Doc
View Source
RegExHexColor
Declaration
public const string RegExHexColor = "^#?([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$"
Field Value
Methods
|
Improve this Doc
View Source
Area(Rectangle)
Declaration
public static int Area(this Rectangle rectangle)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Rectangle |
rectangle |
|
Returns
|
Improve this Doc
View Source
AsRect(FontRectangle)
Declaration
public static RectangleF AsRect(this FontRectangle rectangle)
Parameters
| Type |
Name |
Description |
| SixLabors.Fonts.FontRectangle |
rectangle |
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.RectangleF |
|
|
Improve this Doc
View Source
AsRect(PointF, SizeF)
Declaration
public static RectangleF AsRect(this PointF point, SizeF size)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.PointF |
point |
|
| SixLabors.ImageSharp.SizeF |
size |
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.RectangleF |
|
|
Improve this Doc
View Source
AsRect((Int32 X, Int32 Y, Int32 Width, Int32 Height))
Declaration
public static Rectangle AsRect(this (int X, int Y, int Width, int Height) rect)
Parameters
Returns
| Type |
Description |
| SixLabors.ImageSharp.Rectangle |
|
|
Improve this Doc
View Source
ColorFromHexString(String)
Supports 4 formats:
#RRGGBBAA
RRGGBBAA
#RRGGBB
RRGGBB.
Declaration
public static Color ColorFromHexString(this string color)
Parameters
| Type |
Name |
Description |
| String |
color |
A textual representation of a color.
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.Color |
The Color parsed from the input.
|
|
Improve this Doc
View Source
Crop<T>(Image<T>, Rectangle)
Crop an image using a crop Rectangle.
Declaration
public static Image<T> Crop<T>(this Image<T> source, Rectangle crop)
where T : struct, IPixel<T>
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Image<T> |
source |
Source image.
|
| SixLabors.ImageSharp.Rectangle |
crop |
Crop rectangle.
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.Image<T> |
Cropped image.
|
Type Parameters
|
Improve this Doc
View Source
CropIntersection<T>(Image<T>, Rectangle)
Crop an image using a crop Rectangle.
If crop spills over source only intersecting areas are returned.
Declaration
public static Image<T> CropIntersection<T>(this Image<T> source, Rectangle crop)
where T : struct, IPixel<T>
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Image<T> |
source |
Source image.
|
| SixLabors.ImageSharp.Rectangle |
crop |
Crop rectangle.
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.Image<T> |
Cropped image.
|
Type Parameters
|
Improve this Doc
View Source
CropInverse<T>(Image<T>, Rectangle)
Draw a crop of an image onto a rectangle surface. Unlike crop, it treats the rectangle coordinates
as the source of truth and returns a new image, with a section of source drawn on top.
Declaration
public static Image<T> CropInverse<T>(this Image<T> source, Rectangle crop)
where T : struct, IPixel<T>
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Image<T> |
source |
Source image.
|
| SixLabors.ImageSharp.Rectangle |
crop |
Crop rectangle.
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.Image<T> |
Cropped image.
|
Type Parameters
|
Improve this Doc
View Source
DrawImage(Image, Image, Rectangle, Rectangle)
Declaration
public static void DrawImage(this Image destination, Image source, Rectangle destinationRectangle, Rectangle sourceRectangle)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Image |
destination |
|
| SixLabors.ImageSharp.Image |
source |
|
| SixLabors.ImageSharp.Rectangle |
destinationRectangle |
|
| SixLabors.ImageSharp.Rectangle |
sourceRectangle |
|
|
Improve this Doc
View Source
DrawLine(IImageProcessingContext, Pen, Int32, Int32, Int32, Int32)
Declaration
public static void DrawLine(this IImageProcessingContext context, Pen pen, int x1, int y1, int x2, int y2)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Processing.IImageProcessingContext |
context |
|
| SixLabors.ImageSharp.Drawing.Processing.Pen |
pen |
|
| Int32 |
x1 |
|
| Int32 |
y1 |
|
| Int32 |
x2 |
|
| Int32 |
y2 |
|
|
Improve this Doc
View Source
DrawRectangle(IImageProcessingContext, Pen, Int32, Int32, Int32, Int32)
Declaration
public static void DrawRectangle(this IImageProcessingContext context, Pen pen, int x, int y, int width, int height)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Processing.IImageProcessingContext |
context |
|
| SixLabors.ImageSharp.Drawing.Processing.Pen |
pen |
|
| Int32 |
x |
|
| Int32 |
y |
|
| Int32 |
width |
|
| Int32 |
height |
|
|
Improve this Doc
View Source
DrawTextSafe(IImageProcessingContext, String, Font, Color, PointF, TextGraphicsOptions)
Draws text onto an image.
Declaration
public static void DrawTextSafe(this IImageProcessingContext context, string text, Font font, Color color, PointF location, TextGraphicsOptions textOptions = null)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Processing.IImageProcessingContext |
context |
|
| String |
text |
|
| SixLabors.Fonts.Font |
font |
|
| SixLabors.ImageSharp.Color |
color |
|
| SixLabors.ImageSharp.PointF |
location |
|
| SixLabors.ImageSharp.Drawing.Processing.TextGraphicsOptions |
textOptions |
|
|
Improve this Doc
View Source
DrawVerticalText(IImageProcessingContext, String, Font, Color, Point)
Declaration
public static void DrawVerticalText(this IImageProcessingContext context, string text, Font font, Color color, Point location)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Processing.IImageProcessingContext |
context |
|
| String |
text |
|
| SixLabors.Fonts.Font |
font |
|
| SixLabors.ImageSharp.Color |
color |
|
| SixLabors.ImageSharp.Point |
location |
|
|
Improve this Doc
View Source
FillRectangle(IImageProcessingContext, IBrush, Int32, Int32, Int32, Int32)
Fill a rectangle with a brush.
Declaration
public static void FillRectangle(this IImageProcessingContext context, IBrush brush, int x, int y, int width, int height)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Processing.IImageProcessingContext |
context |
|
| SixLabors.ImageSharp.Drawing.Processing.IBrush |
brush |
|
| Int32 |
x |
|
| Int32 |
y |
|
| Int32 |
width |
|
| Int32 |
height |
|
|
Improve this Doc
View Source
FillWithBlend(IImageProcessingContext, IBrush, IPath[])
Fills a rectangle with color that blends with the background.
If the given brush contains an alpha component,
that component will be used as the BlendPercentage value.
Declaration
public static void FillWithBlend(this IImageProcessingContext context, IBrush brush, params IPath[] paths)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Processing.IImageProcessingContext |
context |
The drawing context.
|
| SixLabors.ImageSharp.Drawing.Processing.IBrush |
brush |
The brush to fill with.
|
| SixLabors.ImageSharp.Drawing.IPath[] |
paths |
If specified, a collection of regions to fill.
|
|
Improve this Doc
View Source
FillWithBlend(IImageProcessingContext, IBrush, RectangleF)
Fills a rectangle with color that blends with the background.
If the given brush contains an alpha component,
that component will be used as the BlendPercentage value.
Declaration
public static void FillWithBlend(this IImageProcessingContext context, IBrush brush, RectangleF region)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Processing.IImageProcessingContext |
context |
The drawing context.
|
| SixLabors.ImageSharp.Drawing.Processing.IBrush |
brush |
The brush to fill with.
|
| SixLabors.ImageSharp.RectangleF |
region |
A rectangular region to fill.
|
|
Improve this Doc
View Source
Returns the Hue-Saturation-Lightness (HSL) lightness
for this Color .
Declaration
public static float GetBrightness(this Rgb24 pixel)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.PixelFormats.Rgb24 |
pixel |
|
Returns
|
Improve this Doc
View Source
Gray(Byte)
Declaration
public static Color Gray(byte tone)
Parameters
| Type |
Name |
Description |
| Byte |
tone |
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.Color |
|
|
Improve this Doc
View Source
MeasureString(IImageProcessingContext, String, Font)
Declaration
public static SizeF MeasureString(this IImageProcessingContext _, string text, Font font)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Processing.IImageProcessingContext |
_ |
|
| String |
text |
|
| SixLabors.Fonts.Font |
font |
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.SizeF |
|
|
Improve this Doc
View Source
ModifySpectrogram(Image, Nullable<Int32>, Nullable<Int32>, Boolean)
Resize sourceImage to match height and width.
Removes DC value if removeBottomRow is true.
Declaration
[Obsolete("This shim only exists for compatibility. Not needed when ImageSharp replaced System.Drawing")]
public static Image ModifySpectrogram(this Image sourceImage, int? height, int? width, bool removeBottomRow)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Image |
sourceImage |
The source Image.
|
| Nullable<Int32> |
height |
The height.
|
| Nullable<Int32> |
width |
The width.
|
| Boolean |
removeBottomRow |
True to remove the DC Value (bottom row of pixels).
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.Image |
Modified image.
|
|
Improve this Doc
View Source
NoAA(IImageProcessingContext)
Declaration
public static Drawing.NoAA NoAA(this IImageProcessingContext context)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Processing.IImageProcessingContext |
context |
|
Returns
|
Improve this Doc
View Source
RotateFlip<T>(Image<T>, RotateFlipType)
Declaration
public static void RotateFlip<T>(this Image<T> image, RotateFlipType operation)
where T : struct, IPixel<T>
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Image<T> |
image |
|
| RotateFlipType |
operation |
|
Type Parameters
|
Improve this Doc
View Source
Save<T>(Image<T>, FileInfo)
Declaration
public static void Save<T>(this Image<T> image, FileInfo path)
where T : struct, IPixel<T>
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Image<T> |
image |
|
| FileInfo |
path |
|
Type Parameters
|
Improve this Doc
View Source
Convert an image to a byte array.
Declaration
public static byte[] ToByteArray(this Image image, IImageEncoder imageFormat)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Image |
image |
The image.
|
| SixLabors.ImageSharp.Formats.IImageEncoder |
imageFormat |
The image Format.
|
Returns
| Type |
Description |
| Byte[] |
Byte array representing image.
|
|
Improve this Doc
View Source
ToHexString(Color, Boolean)
Declaration
public static string ToHexString(this Color color, bool includeAlpha)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Color |
color |
The color.
|
| Boolean |
includeAlpha |
The include alpha.
|
Returns
| Type |
Description |
| String |
Color as hex string.
|
|
Improve this Doc
View Source
ToImage(Byte[])
Get Image from byte array.
Declaration
public static Image ToImage(this byte[] bytes)
Parameters
| Type |
Name |
Description |
| Byte[] |
bytes |
The byte array.
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.Image |
Image from byte array.
|
|
Improve this Doc
View Source
ToPen(Color, Single)
Declaration
public static Pen ToPen(this Color color, float width = 1F)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.Color |
color |
|
| Single |
width |
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.Drawing.Processing.Pen |
|
|
Improve this Doc
View Source
ToSize(SizeF)
Declaration
public static Size ToSize(this SizeF size)
Parameters
| Type |
Name |
Description |
| SixLabors.ImageSharp.SizeF |
size |
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.Size |
|
|
Improve this Doc
View Source
ToSizeF(FontRectangle)
Declaration
public static SizeF ToSizeF(this FontRectangle rectangle)
Parameters
| Type |
Name |
Description |
| SixLabors.Fonts.FontRectangle |
rectangle |
|
Returns
| Type |
Description |
| SixLabors.ImageSharp.SizeF |
|