Scanline

Description

sealed class Tinman.Terrain.Imaging.Scanline

This class represents the scanline data of an image and provides methods for pixel manipulation.

Image processing is performed scanline after scanline. Regardless of the actual pixel format of an image, during processing scanline pixels are represented as 96-bit color values with 24-bits for each color channel (see Pixels).

An image can contain void pixels. These pixels do not store data and thus represent holes in the image data. Void pixels are represented by the out-of-range pixel channel value -1.

Public / Constructors

For


public static method For → (1)

image in : IImageInfo

[not-null]
The image.

returns → Scanline

The scanline buffer.

Creates a new instance of Scanline for the given image.

Scanline


public constructor Scanline → (2)

width in : int32

[>=0]
The scanline width, in pixels.

format opt : PixelFormat = PixelFormat.Default

The pixel format.

Creates a new instance of Scanline.

Public / Methods

Alpha_16


[Pure]
public method Alpha_16 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The alpha channel value or -1 if the pixel is void.

Returns the alpha channel of a pixel (16 bits precision).

Alpha_24


[Pure]
public method Alpha_24 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The alpha channel value or -1 if the pixel is void.

Returns the alpha channel of a pixel (24 bits precision).

Alpha_8


[Pure]
public method Alpha_8 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The alpha channel value or -1 if the pixel is void.

Returns the alpha channel of a pixel (8 bits precision).

Blue_16


[Pure]
public method Blue_16 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The blue channel value (linear sRGB) or -1 if the pixel is void.

Returns the blue channel of a pixel (16 bits precision).

Blue_24


[Pure]
public method Blue_24 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The blue channel value (linear sRGB) or -1 if the pixel is void.

Returns the blue channel of a pixel (24 bits precision).

Blue_8


[Pure]
public method Blue_8 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The blue channel value (compressed sRGB) or -1 if the pixel is void.

Returns the blue channel of a pixel (8 bits precision).

Channel

2 overloads


public method Channel1 → (2)

in : int32

X-coordinate of pixel.

channel in : PixelChannel

The pixel channel.

returns → int32

The pixel channel value (linear sRGB) or -1 if the pixel is void (except when channel in is PixelChannel.Void).

Returns a channel value of the given pixel.


public method Channel2 → (3)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

channel in : PixelChannel

The pixel channel.

value in : int32

[0..16777215]
The pixel channel value (linear sRGB).

Sets a channel value of the given pixel.

Copy


public method Copy → (4)

sourceX in : int32

[0..Scanline.Width-count]
X-coordinate of first pixel to copy.

target in : Scanline

[not-null]
The target scanline.

targetX in : int32

[0..target.Width-count]
X-coordinate of first pixel in target in to write.

count opt : int32 = 1

[>=0]
Number of pixels to copy.

Copies zero or more pixels from this scanline to the given one.

Get_​RGB_16


[Pure]
public method Get_RGB_16 → (2)

in : int32

X-coordinate of pixel.

voidColor opt : int64 = Colors.White

The color value to return if the pixel is void.

returns → int64

The color value (see Colors).

Returns a pixel of the scanline as a 64-bit A16R16G16B16 linear sRGB color value.

Green_16


[Pure]
public method Green_16 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The green channel value (linear sRGB) or -1 if the pixel is void.

Returns the green channel of a pixel (16 bits precision).

Green_24


[Pure]
public method Green_24 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The green channel value (linear sRGB) or -1 if the pixel is void.

Returns the green channel of a pixel (24 bits precision).

Green_8


[Pure]
public method Green_8 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The green channel value (compressed sRGB) or -1 if the pixel is void.

Returns the green channel of a pixel (8 bits precision).

Intensity_16


[Pure]
public method Intensity_16 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The grayscale intensity channel value (linear sRGB) or -1 if the pixel is void.

Returns the grayscale intensity channel of a pixel (16 bits precision).

Intensity_24


[Pure]
public method Intensity_24 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The grayscale intensity channel value (linear sRGB) or -1 if the pixel is void.

Returns the grayscale intensity channel of a pixel (24 bits precision).

Intensity_8


[Pure]
public method Intensity_8 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The grayscale intensity channel value (compressed sRGB) or -1 if the pixel is void.

Returns the grayscale intensity channel of a pixel (8 bits precision).

Red_16


[Pure]
public method Red_16 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The red channel value (linear sRGB) or -1 if the pixel is void.

Returns the red channel of a pixel (16 bits precision).

Red_24


[Pure]
public method Red_24 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The red channel value (linear sRGB) or -1 if the pixel is void.

Returns the red channel of a pixel (24 bits precision).

Red_8


[Pure]
public method Red_8 → (1)

in : int32

X-coordinate of pixel.

returns → int32

The red channel value (compressed sRGB) or -1 if the pixel is void.

Returns the red channel of a pixel (8 bits precision).

Set_​I_16


public method Set_I_16 → (3)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

intensity16 in : int32

[0..65535]
Grayscale intensity value of pixel (linear sRGB).

alpha16 opt : int32 = 65535

[-1..65535]
Alpha value of pixel. If -1, the alpha channel will be left unmodified.

Sets a pixel of the scanline (16 bits precision).

Set_​I_24


public method Set_I_24 → (3)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

intensity24 in : int32

[0..16777215]
Grayscale intensity value of pixel (linear sRGB).

alpha24 opt : int32 = 16777215

[-1..16777215]
Alpha value of pixel. If -1, the alpha channel will be left unmodified.

Sets a pixel of the scanline (24 bits precision).

Set_​I_8


public method Set_I_8 → (3)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

intensity8 in : int32

[0..255]
Grayscale intensity value of pixel (compressed sRGB).

alpha8 opt : int32 = 255

[-1..255]
Alpha value of pixel. If -1, the alpha channel will be left unmodified.

Sets a pixel of the scanline (8 bits precision).

Set_​RGB_16

2 overloads


public method Set_RGB_161 → (2)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

color in : int64

The 64-bit A16R16G16B16 linear sRGB color value.

Sets a pixel of the scanline (16 bits precision).

See also

Colors


public method Set_RGB_162 → (5)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

red16 in : int32

[0..65535]
Red channel value of pixel (linear sRGB).

green16 in : int32

[0..65535]
Green channel value of pixel (linear sRGB).

blue16 in : int32

[0..65535]
Blue channel value of pixel (linear sRGB).

alpha16 opt : int32 = 65535

[-1..65535]
Alpha value of pixel. If -1, the alpha channel will be left unmodified.

Sets a pixel of the scanline (16 bits precision).

Set_​RGB_24


public method Set_RGB_24 → (5)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

red24 in : int32

[0..16777215]
Red channel value of pixel (linear sRGB).

green24 in : int32

[0..16777215]
Green channel value of pixel (linear sRGB).

blue24 in : int32

[0..16777215]
Blue channel value of pixel (linear sRGB).

alpha24 opt : int32 = 16777215

[-1..16777215]
Alpha value of pixel. If -1, the alpha channel will be left unmodified.

Sets a pixel of the scanline (24 bits precision).

Set_​RGB_8

2 overloads


public method Set_RGB_81 → (2)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

color in : int32

The 32-bit A8R8G8B8 compressed sRGB color value.

Sets a pixel of the scanline (8 bits precision).

See also

Colors


public method Set_RGB_82 → (5)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

red8 in : int32

[0..255]
Red channel value of pixel (compressed sRGB).

green8 in : int32

[0..255]
Green channel value of pixel (compressed sRGB).

blue8 in : int32

[0..255]
Blue channel value of pixel (compressed sRGB).

alpha8 opt : int32 = 255

[-1..255]
Alpha value of pixel. If -1, the alpha channel will be left unmodified.

Sets a pixel of the scanline (8 bits precision).

Set_​Void


public method Set_Void → (1)

in : int32

[0..Scanline.Width-1]
X-coordinate of pixel.

Sets a pixel of the scanline to void (i.e. it will represent missing data).

Transform


public method Transform → (2)

in : float64

Transform coefficient (see remarks).

in : float64

Transform coefficient (see remarks).

Applies a linear transform to all non-void pixel values.

Each pixel channel value x will be transformed to y according to this formula:

y = x < 0 ? -1 : clamp(m * x + b, 0, 16777215)

Transforming a void pixel will also yield a void pixel.

Void


[Pure]
public method Void → (1)

in : int32

X-coordinate of pixel.

returns → bool

true if the pixel is void, false if not.

Returns if a pixel is void, i.e. it represents missing data.

Void​Replace


public method VoidReplace → (2)

voidColor opt : int64 = 0

The replacement color for void pixels.

nonVoidColor opt : int64 = ~0

The replacement color for non-void pixels.

returns → int32

<0 : All pixels are void
0 : Some pixels are void, some are not.
>0 : No pixels are void.

Replaces all void pixels with the given first color and sets all other pixels to the given second color.

Public / Attributes

Format


public attribute Format → (get,set)

value : PixelFormat

The pixel format.

The pixel format of the scanline.

This property is set by image readers for informational purposes only. It does not affect pixel processing.

Pixels


public readonly attribute Pixels → (int32 [ ])

The pixels of the scanline.

Pixel data is always processed in an uniform layout that is independent of the actual PixelFormat of the image:

+---+---+---+---+---+---+---+---+---+---+---+---+-----+---+---+---+---+
| R | G | B | A | R | G | B | A | R | G | B | A |     | R | G | B | A |
+---+---+---+---+---+---+---+---+---+---+---+---+ ... +---+---+---+---+
|    Pixel 0    |    Pixel 1    |    Pixel 0    |     | Pixel Width-1 |
+---------------+---------------+---------------+-----+---------------+

Each of color channels R, G, B and A are encoded as an unsigned 24-bit integer value in the range [0..16777215].

An image may contain pixels that represent missing data and thus do not have a value. For those pixels, all channel values are set to -1. It is sufficient to test if any channel value is less than zero for determining if a pixel is void.

This array can be indexed as follows:

Pixels[x * 4 + 0] := red channel value in the range [0..16777215] or -1 if void pixel.
Pixels[x * 4 + 1] := green channel value in the range [0..16777215] or -1 if void pixel.
Pixels[x * 4 + 2] := blue channel value in the range [0..16777215] or -1 if void pixel.
Pixels[x * 4 + 3] := alpha channel value in the range [0..16777215] or -1 if void pixel.

where x is the X-coordinate of a pixel in the Scanline.

Range


public attribute Range → (get,set)

value : PixelRange

The pixel range.

The pixel range of the scanline.

This property is set by image readers for informational purposes only. It does not affect pixel processing.

Width


public readonly attribute Width → (int32)

The scanline width, in pixels.