ValueMap¶
Namespace Nfty.Core.Editing in assembly Nfty.Core.
Editable single-layer raster: one grayscale value (0–255) plus one alpha (0–255) per pixel, bound to a fixed canvas size. Grayscale is guaranteed by construction — there is no way to store independent R/G/B. Materialize an Image only at export/preview.
Remarks¶
It is an IEditSurface<TPixel>, which is how the generic paint stack reaches it. That costs the guarantee nothing: GrayPixel carries one value and one alpha, so a command written against the generic surface has no color to hand this map even if it holds one. Nothing on this type accepts independent R/G/B, and nothing should be added that does.
Constructors¶
ValueMap(int, int)¶
Creates a blank map.
Parameters
width(int) - Width in pixels; must be positive.height(int) - Height in pixels; must be positive.
Exceptions
ArgumentOutOfRangeException- Either dimension is zero or negative.
Properties¶
Height¶
Height in pixels.
Width¶
Width in pixels.
Methods¶
AlphaOf(GrayPixel)¶
The alpha channel of a pixel in this surface's format.
Parameters
pixel(GrayPixel) - The pixel to read.
Returns. Alpha, 0-255.
Clone()¶
An independent deep copy — cloned value/alpha buffers, same dimensions.
Returns. A new map with its own buffers.
ForCanvas(Dimensions)¶
A blank map at the CookBook's canvas size.
Parameters
canvas(Dimensions) - The canvas to match.
Returns. A new map.
FromImage(Image<Rgba32>)¶
Reads a map back out of a decoded variant image.
Parameters
img(Image<Rgba32>) - The source image.
Returns. A new map.
Get(int, int)¶
The pixel at a coordinate, as the generic paint stack sees it.
Parameters
x(int) - Column.y(int) - Row.
Returns. Its value and alpha.
GetAlpha(int, int)¶
The alpha at a pixel.
Parameters
x(int) - Column.y(int) - Row.
Returns. 0-255.
GetValue(int, int)¶
The grayscale value at a pixel.
Parameters
x(int) - Column.y(int) - Row.
Returns. 0-255.
InBounds(int, int)¶
Whether a coordinate is inside the map.
Parameters
x(int) - Column.y(int) - Row.
Returns. True when the pixel exists.
Set(int, int, GrayPixel)¶
Writes one pixel. Out-of-bounds coordinates are ignored.
Parameters
x(int) - Column.y(int) - Row.pixel(GrayPixel) - The value and alpha to store.
Set(int, int, byte, byte)¶
Writes one pixel. Out-of-bounds coordinates are ignored, so a brush may run off the edge without the caller clipping first.
Parameters
x(int) - Column.y(int) - Row.value(byte) - Grayscale value.alpha(byte) - Alpha.
ToImage()¶
Renders to a grayscale RGBA image — the form an .igt stores.
Returns. A new image; the caller owns it.
WithAlpha(GrayPixel, byte)¶
The same pixel with its alpha replaced and every other channel untouched.
Parameters
pixel(GrayPixel) - The pixel to rewrite.alpha(byte) - The alpha it should carry.
Returns. A pixel identical to pixel apart from its alpha.