Class MutableImage
This class represents a libvips image which can be modified. See Mutate(Action<MutableImage>).
Implements
Inherited Members
Namespace: NetVips
Assembly: NetVips.dll
Syntax
public sealed class MutableImage : Image, IDisposable
Properties
this[int]
Overload []
.
Declaration
public Image this[int i] { set; }
Parameters
Type | Name | Description |
---|---|---|
int | i | The band element to change. |
Property Value
Type | Description |
---|---|
Image |
Remarks
Use []
to set band elements on an image. For example:
using var test = image.Mutate(x => x[1] = green);
Will change band 1 (the middle band).
Methods
DrawCircle(double[], int, int, int, bool?)
Draw a circle on an image.
Declaration
public void DrawCircle(double[] ink, int cx, int cy, int radius, bool? fill = null)
Parameters
Type | Name | Description |
---|---|---|
double[] | ink | Color for pixels. |
int | cx | Centre of draw_circle. |
int | cy | Centre of draw_circle. |
int | radius | Radius in pixels. |
bool? | fill | Draw a solid object. |
Examples
image.Mutate(x => x.DrawCircle(ink, cx, cy, radius, fill: bool));
DrawFlood(double[], int, int, Image, bool?)
Flood-fill an area.
Declaration
public void DrawFlood(double[] ink, int x, int y, Image test = null, bool? equal = null)
Parameters
Type | Name | Description |
---|---|---|
double[] | ink | Color for pixels. |
int | x | DrawFlood start point. |
int | y | DrawFlood start point. |
Image | test | Test pixels in this image. |
bool? | equal | DrawFlood while equal to edge. |
Examples
image.Mutate(x => x.DrawFlood(ink, x, y, test: Image, equal: bool));
DrawFlood(double[], int, int, out int, Image, bool?)
Flood-fill an area.
Declaration
public void DrawFlood(double[] ink, int x, int y, out int left, Image test = null, bool? equal = null)
Parameters
Type | Name | Description |
---|---|---|
double[] | ink | Color for pixels. |
int | x | DrawFlood start point. |
int | y | DrawFlood start point. |
int | left | Left edge of modified area. |
Image | test | Test pixels in this image. |
bool? | equal | DrawFlood while equal to edge. |
Examples
image.Mutate(x => x.DrawFlood(ink, x, y, out var left, test: Image, equal: bool));
DrawFlood(double[], int, int, out int, out int, Image, bool?)
Flood-fill an area.
Declaration
public void DrawFlood(double[] ink, int x, int y, out int left, out int top, Image test = null, bool? equal = null)
Parameters
Type | Name | Description |
---|---|---|
double[] | ink | Color for pixels. |
int | x | DrawFlood start point. |
int | y | DrawFlood start point. |
int | left | Left edge of modified area. |
int | top | Top edge of modified area. |
Image | test | Test pixels in this image. |
bool? | equal | DrawFlood while equal to edge. |
Examples
image.Mutate(x => x.DrawFlood(ink, x, y, out var left, out var top, test: Image, equal: bool));
DrawFlood(double[], int, int, out int, out int, out int, Image, bool?)
Flood-fill an area.
Declaration
public void DrawFlood(double[] ink, int x, int y, out int left, out int top, out int width, Image test = null, bool? equal = null)
Parameters
Type | Name | Description |
---|---|---|
double[] | ink | Color for pixels. |
int | x | DrawFlood start point. |
int | y | DrawFlood start point. |
int | left | Left edge of modified area. |
int | top | Top edge of modified area. |
int | width | Width of modified area. |
Image | test | Test pixels in this image. |
bool? | equal | DrawFlood while equal to edge. |
Examples
image.Mutate(x => x.DrawFlood(ink, x, y, out var left, out var top, out var width, test: Image, equal: bool));
DrawFlood(double[], int, int, out int, out int, out int, out int, Image, bool?)
Flood-fill an area.
Declaration
public void DrawFlood(double[] ink, int x, int y, out int left, out int top, out int width, out int height, Image test = null, bool? equal = null)
Parameters
Type | Name | Description |
---|---|---|
double[] | ink | Color for pixels. |
int | x | DrawFlood start point. |
int | y | DrawFlood start point. |
int | left | Left edge of modified area. |
int | top | Top edge of modified area. |
int | width | Width of modified area. |
int | height | Height of modified area. |
Image | test | Test pixels in this image. |
bool? | equal | DrawFlood while equal to edge. |
Examples
image.Mutate(x => x.DrawFlood(ink, x, y, out var left, out var top, out var width, out var height, test: Image, equal: bool));
DrawImage(Image, int, int, CombineMode?)
Paint an image into another image.
Declaration
public void DrawImage(Image sub, int x, int y, Enums.CombineMode? mode = null)
Parameters
Type | Name | Description |
---|---|---|
Image | sub | Sub-image to insert into main image. |
int | x | Draw image here. |
int | y | Draw image here. |
Enums.CombineMode? | mode | Combining mode. |
Examples
image.Mutate(x => x.DrawImage(sub, x, y, mode: Enums.CombineMode));
DrawLine(double[], int, int, int, int)
Draw a line on an image.
Declaration
public void DrawLine(double[] ink, int x1, int y1, int x2, int y2)
Parameters
Type | Name | Description |
---|---|---|
double[] | ink | Color for pixels. |
int | x1 | Start of draw_line. |
int | y1 | Start of draw_line. |
int | x2 | End of draw_line. |
int | y2 | End of draw_line. |
Examples
image.Mutate(x => x.DrawLine(ink, x1, y1, x2, y2));
DrawMask(double[], Image, int, int)
Draw a mask on an image.
Declaration
public void DrawMask(double[] ink, Image mask, int x, int y)
Parameters
Type | Name | Description |
---|---|---|
double[] | ink | Color for pixels. |
Image | mask | Mask of pixels to draw. |
int | x | Draw mask here. |
int | y | Draw mask here. |
Examples
image.Mutate(x => x.DrawMask(ink, mask, x, y));
DrawRect(double[], int, int, int, int, bool?)
Paint a rectangle on an image.
Declaration
public void DrawRect(double[] ink, int left, int top, int width, int height, bool? fill = null)
Parameters
Type | Name | Description |
---|---|---|
double[] | ink | Color for pixels. |
int | left | Rect to fill. |
int | top | Rect to fill. |
int | width | Rect to fill. |
int | height | Rect to fill. |
bool? | fill | Draw a solid object. |
Examples
image.Mutate(x => x.DrawRect(ink, left, top, width, height, fill: bool));
DrawSmudge(int, int, int, int)
Blur a rectangle on an image.
Declaration
public void DrawSmudge(int left, int top, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
int | left | Rect to fill. |
int | top | Rect to fill. |
int | width | Rect to fill. |
int | height | Rect to fill. |
Examples
image.Mutate(x => x.DrawSmudge(left, top, width, height));
Mutate(Action<MutableImage>)
The Image this MutableImage is modifying. Only use this once you have finished all modifications.
Declaration
public override Image Mutate(Action<MutableImage> action)
Parameters
Type | Name | Description |
---|---|---|
Action<MutableImage> | action |
Returns
Type | Description |
---|---|
Image |
Overrides
Remove(string)
Remove an item of metadata.
Declaration
public bool Remove(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the piece of metadata to remove. |
Returns
Type | Description |
---|---|
bool | true if the metadata is successfully removed; otherwise, false. |
Remarks
The named metadata item is removed.
Set(nint, string, object)
Set the type and value of an item of metadata.
Declaration
public void Set(nint gtype, string name, object value)
Parameters
Type | Name | Description |
---|---|---|
nint | gtype | The GType of the metadata item to create. |
string | name | The name of the piece of metadata to create. |
object | value | The value to set as a C# value. It is converted to the GType, if possible. |
Remarks
Sets the type and value of an item of metadata. Any old item of the same name is removed. See GValue for types.
Set(string, object)
Set the value of an item of metadata.
Declaration
public void Set(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the piece of metadata to set the value of. |
object | value | The value to set as a C# value. It is converted to the type of the metadata item, if possible. |
Remarks
Sets the value of an item of metadata. The metadata item must already exist.
Exceptions
Type | Condition |
---|---|
ArgumentException | If metadata item |
ToString()
The Image this MutableImage is modifying. Only use this once you have finished all modifications.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |