This class represents the scanline data of an image and provides methods for pixel manipulation.
sealed class
|
Scanline
|
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
.
The pixel format of the scanline.
public
property
|
Format
{
get
set
}
|
||
type
|
PixelFormat
|
||
value
|
The pixel format. |
Remarks:
This property is set by image readers for informational purposes only. It does not affect pixel processing.
The pixels of the scanline.
public
readonly
field
|
Pixels
|
||
type
|
int32[]
|
Remarks:
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.
The pixel range of the scanline.
public
property
|
Range
{
get
set
}
|
||
type
|
PixelRange
|
||
value
|
The pixel range. |
Remarks:
This property is set by image readers for informational purposes only. It does not affect pixel processing.
The scanline width, in pixels.
public
readonly
field
|
Width
|
||
type
|
int32
|
Creates a new instance of Scanline for the given image.
public
static
method
|
For
(IImageInfo image)
|
||
type
|
Scanline
|
||
params
|
image
|
[not-null]
|
The image. |
returns
|
|
The scanline buffer. |
Creates a new instance of Scanline.
public
constructor
|
Scanline
(int32 width,
PixelFormat format = PixelFormat.Default)
|
||
params
|
width
|
[>=0]
|
The scanline width, in pixels. |
format
|
The pixel format. Defaults to Default. |
Returns the alpha channel of a pixel (16 bits precision).
[Pure]
|
||||
public
method
|
Alpha_16
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
alpha
channel
value
or
-1
if
the
pixel
is
void. |
Returns the alpha channel of a pixel (24 bits precision).
[Pure]
|
||||
public
method
|
Alpha_24
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
alpha
channel
value
or
-1
if
the
pixel
is
void.
|
Returns the alpha channel of a pixel (8 bits precision).
[Pure]
|
||||
public
method
|
Alpha_8
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
alpha
channel
value
or
-1
if
the
pixel
is
void. |
Returns the blue channel of a pixel (16 bits precision).
[Pure]
|
||||
public
method
|
Blue_16
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
blue
channel
value
(linear
sRGB)
or
-1
if
the
pixel
is
void.
|
Returns the blue channel of a pixel (24 bits precision).
[Pure]
|
||||
public
method
|
Blue_24
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
blue
channel
value
(linear
sRGB)
or
-1
if
the
pixel
is
void.
|
Returns the blue channel of a pixel (8 bits precision).
[Pure]
|
||||
public
method
|
Blue_8
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
blue
channel
value
(compressed
sRGB)
or
-1
if
the
pixel
is
void.
|
Returns a channel value of the given pixel.
public
method
|
Channel
(int32 x,
PixelChannel channel)
|
||
type
|
int32
|
||
params
|
x
|
X-coordinate of pixel. | |
channel
|
The pixel channel. | ||
returns
|
|
The
pixel
channel
value
(linear
sRGB)
or
-1
if
the
pixel
is
void
(except
when
channel
is
Void).
|
Sets a channel value of the given pixel.
public
method
|
Channel
(int32 x,
PixelChannel channel,
int32 value)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
channel
|
The pixel channel. | ||
value
|
[0..16777215]
|
The pixel channel value (linear sRGB). |
Copies zero or more pixels from this scanline to the given one.
public
method
|
Copy
(int32 sourceX,
Scanline target,
int32 targetX,
int32 count = 1)
|
||
params
|
sourceX
|
[0..Width-count]
|
X-coordinate of first pixel to copy. |
target
|
[not-null]
|
The target scanline. | |
targetX
|
[0..target.Width-count]
|
X-coordinate of first pixel in target to write. | |
count
|
[>=0]
|
Number
of
pixels
to
copy.
Defaults
to
1 . |
Returns a pixel of the scanline as a 64-bit A16R16G16B16 linear sRGB color value.
[Pure]
|
||||
public
method
|
Get_RGB_16
(int32 x,
int64 voidColor = Colors.White)
|
|||
type
|
int64
|
|||
params
|
x
|
X-coordinate of pixel. | ||
voidColor
|
The color value to return if the pixel is void. Defaults to White. | |||
returns
|
The color value (see Colors). |
Returns the green channel of a pixel (16 bits precision).
[Pure]
|
||||
public
method
|
Green_16
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
green
channel
value
(linear
sRGB)
or
-1
if
the
pixel
is
void.
|
Returns the green channel of a pixel (24 bits precision).
[Pure]
|
||||
public
method
|
Green_24
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
green
channel
value
(linear
sRGB)
or
-1
if
the
pixel
is
void.
|
Returns the green channel of a pixel (8 bits precision).
[Pure]
|
||||
public
method
|
Green_8
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
green
channel
value
(compressed
sRGB)
or
-1
if
the
pixel
is
void.
|
Returns the grayscale intensity channel of a pixel (16 bits precision).
[Pure]
|
||||
public
method
|
Intensity_16
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
grayscale
intensity
channel
value
(linear
sRGB)
or
-1
if
the
pixel
is
void.
|
See also:
Colors.GrayscaleFReturns the grayscale intensity channel of a pixel (24 bits precision).
[Pure]
|
||||
public
method
|
Intensity_24
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
grayscale
intensity
channel
value
(linear
sRGB)
or
-1
if
the
pixel
is
void.
|
See also:
Colors.GrayscaleFReturns the grayscale intensity channel of a pixel (8 bits precision).
[Pure]
|
||||
public
method
|
Intensity_8
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
grayscale
intensity
channel
value
(compressed
sRGB)
or
-1
if
the
pixel
is
void.
|
See also:
Colors.GrayscaleFReturns the red channel of a pixel (16 bits precision).
[Pure]
|
||||
public
method
|
Red_16
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
red
channel
value
(linear
sRGB)
or
-1
if
the
pixel
is
void.
|
Returns the red channel of a pixel (24 bits precision).
[Pure]
|
||||
public
method
|
Red_24
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
red
channel
value
(linear
sRGB)
or
-1
if
the
pixel
is
void.
|
Returns the red channel of a pixel (8 bits precision).
[Pure]
|
||||
public
method
|
Red_8
(int32 x)
|
|||
type
|
int32
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
|
The
red
channel
value
(compressed
sRGB)
or
-1
if
the
pixel
is
void.
|
Sets a pixel of the scanline (16 bits precision).
public
method
|
Set_I_16
(int32 x,
int32 intensity16,
int32 alpha16 = 65535)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
intensity16
|
[0..65535]
|
Grayscale intensity value of pixel (linear sRGB). | |
alpha16
|
[-1..65535]
|
Alpha
value
of
pixel.
If
-1 ,
the
alpha
channel
will
be
left
unmodified.
Defaults
to
65535 .
|
Sets a pixel of the scanline (24 bits precision).
public
method
|
Set_I_24
(int32 x,
int32 intensity24,
int32 alpha24 = 16777215)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
intensity24
|
[0..16777215]
|
Grayscale intensity value of pixel (linear sRGB). | |
alpha24
|
[-1..16777215]
|
Alpha
value
of
pixel.
If
-1 ,
the
alpha
channel
will
be
left
unmodified.
Defaults
to
16777215 .
|
Sets a pixel of the scanline (8 bits precision).
public
method
|
Set_I_8
(int32 x,
int32 intensity8,
int32 alpha8 = 255)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
intensity8
|
[0..255]
|
Grayscale intensity value of pixel (compressed sRGB). | |
alpha8
|
[-1..255]
|
Alpha
value
of
pixel.
If
-1 ,
the
alpha
channel
will
be
left
unmodified.
Defaults
to
255 .
|
Sets a pixel of the scanline (16 bits precision).
public
method
|
Set_RGB_16
(int32 x,
int64 color)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
color
|
The 64-bit A16R16G16B16 linear sRGB color value. |
See also:
ColorsSets a pixel of the scanline (16 bits precision).
public
method
|
Set_RGB_16
(int32 x,
int32 red16,
int32 green16,
int32 blue16,
int32 alpha16 = 65535)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
red16
|
[0..65535]
|
Red channel value of pixel (linear sRGB). | |
green16
|
[0..65535]
|
Green channel value of pixel (linear sRGB). | |
blue16
|
[0..65535]
|
Blue channel value of pixel (linear sRGB). | |
alpha16
|
[-1..65535]
|
Alpha
value
of
pixel.
If
-1 ,
the
alpha
channel
will
be
left
unmodified.
Defaults
to
65535 .
|
Sets a pixel of the scanline (24 bits precision).
public
method
|
Set_RGB_24
(int32 x,
int32 red24,
int32 green24,
int32 blue24,
int32 alpha24 = 16777215)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
red24
|
[0..16777215]
|
Red channel value of pixel (linear sRGB). | |
green24
|
[0..16777215]
|
Green channel value of pixel (linear sRGB). | |
blue24
|
[0..16777215]
|
Blue channel value of pixel (linear sRGB). | |
alpha24
|
[-1..16777215]
|
Alpha
value
of
pixel.
If
-1 ,
the
alpha
channel
will
be
left
unmodified.
Defaults
to
16777215 .
|
Sets a pixel of the scanline (8 bits precision).
public
method
|
Set_RGB_8
(int32 x,
int32 color)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
color
|
The 32-bit A8R8G8B8 compressed sRGB color value. |
See also:
ColorsSets a pixel of the scanline (8 bits precision).
public
method
|
Set_RGB_8
(int32 x,
int32 red8,
int32 green8,
int32 blue8,
int32 alpha8 = 255)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
red8
|
[0..255]
|
Red channel value of pixel (compressed sRGB). | |
green8
|
[0..255]
|
Green channel value of pixel (compressed sRGB). | |
blue8
|
[0..255]
|
Blue channel value of pixel (compressed sRGB). | |
alpha8
|
[-1..255]
|
Alpha
value
of
pixel.
If
-1 ,
the
alpha
channel
will
be
left
unmodified.
Defaults
to
255 .
|
Sets a pixel of the scanline to void (i.e. it will represent missing data).
public
method
|
Set_Void
(int32 x)
|
||
params
|
x
|
[0..Width-1]
|
X-coordinate of pixel. |
Applies a linear transform to all non-void pixel values.
public
method
|
Transform
(float64 m,
float64 b)
|
||
params
|
m
|
Transform coefficient (see remarks). | |
b
|
Transform coefficient (see remarks). |
Remarks:
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.
Returns if a pixel is void, i.e. it represents missing data.
[Pure]
|
||||
public
method
|
Void
(int32 x)
|
|||
type
|
bool
|
|||
params
|
x
|
X-coordinate of pixel. | ||
returns
|
true
if
the
pixel
is
void,
false
if
not. |
Replaces all void pixels with the given first color and sets all other pixels to the given second color.
public
method
|
VoidReplace
(int64 voidColor = 0,
int64 nonVoidColor = ~0)
|
||
type
|
int32
|
||
params
|
voidColor
|
The
replacement
color
for
void
pixels.
Defaults
to
0 .
|
|
nonVoidColor
|
The
replacement
color
for
non-void
pixels.
Defaults
to
~0 .
|
||
returns
|
<0 :
All
pixels
are
void
0 :
Some
pixels
are
void,
some
are
not.
>0 :
No
pixels
are
void.
|