ISampleBuffer

Description

interface Tinman.Terrain.Buffers.ISampleBuffer

Derived from

ISampleBufferBase
IEquatable<ISampleBuffer>

Extended by

SampleBuffer abstract

Base interface for classes that represent buffers for heightmap sample values.

Subclasses provide an array that stores the buffer samples. This array can be accessed as follows:

Samples[Offset + y * Stride + x * TupleSize + z] := value

where x and y are the coordinates of the buffer sample and z is the index of the tuple component to access.

Public / Methods

ApplyTransform


public method ApplyTransform → (5)

in : int32

[0..ISampleBufferBase.Width]
X-coordinate of top-left sample of region.

in : int32

[0..ISampleBufferBase.Height]
Y-coordinate of top-left sample of region.

width in : int32

[0..ISampleBufferBase.Width-x]
Width of region to transform.

height in : int32

[0..ISampleBufferBase.Height-y]
Height of region to transform.

transform in : Transform

The 2D transform to apply.

Perform an in-place Transform of the samples in the given region.

For square regions (i.e. same width and height), all Transforms can be applied in-place. For rectangular regions, width and height might be swapped ( Transforms.WillSwapAxes) while the top-left sample of the given region remains in the same place.

If this sample buffer is not big enough to hold the swapped width resp. height, output samples will be discarded.

This method reads samples from the given input region and writes samples to the transformed output region. No other sample are accessed by this method.

Clear


public method Clear → (5)

opt : int32 = 0

[0..ISampleBufferBase.Width]
X-coordinate of top-left buffer sample to clear.

opt : int32 = 0

[0..ISampleBufferBase.Height]
Y-coordinate of top-left buffer sample to clear.

countX opt : int32 = -1

[>=-1]
Number of buffer samples to clear along X-axis. If -1, samples up to the right buffer edge will be cleared.

countY opt : int32 = -1

[>=-1]
Number of buffer samples to clear along Y-axis. If -1, samples down to the bottom buffer edge will be cleared.

step opt : int32 = 1

[>=1]
The step distance between buffer samples.

Clears buffer samples to their default value(s).

Clone


public method Clone → ()

returns → ISampleBuffer

The clones sample buffer.

Clones the sample buffer.

The original and cloned buffers will share the buffer samples. Use this method if you need a separate buffer instance (e.g. for configuring buffer specific properties while keeping the original buffer unmodified).

Pack


public method Pack → ()

returns → ISampleBuffer

The packed sample buffer object.

Returns a densely packed sample buffer object that contains the same data as this buffer.

ScaleOffset


public method ScaleOffset → (2)

scale in : float64

The scale factor.

offset opt : float64 = 0

The offset value.

Scales the buffer samples and adds the given offset.

Each tuple component (see TupleSize) of each buffer sample is modified according to this formula:

v' := clamp(round(scale * v + offset))

where v is the sample value currently present in the buffer, v' is the transformed sample and clamp and round are some buffer specific functions that convert the transformed samples back to valid buffer values.

ScanlineRead


public method ScanlineRead → (2)

in : int32

Y-coordinate of samples to transfer.

scanline in : Scanline

The buffer that holds the scanline pixels.

Transfers image pixels into the sample buffer.

ScanlineWrite


public method ScanlineWrite → (2)

in : int32

Y-coordinate of samples to transfer.

scanline in : Scanline

The buffer that holds the scanline pixels.

Transfers buffer samples to the image scanline.

SubBuffer


public method SubBuffer → (4)

in : int32

[0..ISampleBufferBase.Width-width]
X-coordinate of top-left sample of subregion.

in : int32

[0..ISampleBufferBase.Height-height]
Y-coordinate of top-left sample of subregion.

width in : int32

[1..ISampleBufferBase.Width]
Width of subregion.

height in : int32

[1..ISampleBufferBase.Height]
Height of subregion.

returns → ISampleBuffer

The subregion of this sample buffer.

Represents an ISampleBuffer object that represents a rectangular subregion of this sample buffer.

Modifications made to this sample buffer will be visible to the returned buffer and vice versa.

Public / Attributes

ScanlineFormat


public attribute ScanlineFormat → (get)

value : PixelFormat

The pixel format.

The PixelFormat of this sample buffer, when being read as an image.

ScanlineRange


public attribute ScanlineRange → (get,set)

value : PixelRange

The pixel range.

The PixelRange of this buffer, where raw pixels values correspond to the buffer samples.

TupleSize


public attribute TupleSize → (get)

value : int32

[1..4]
The buffer sample tuple size.

The tuple size of each buffer sample (i.e. the number of array elements).

Extensions

ReadAsImage


[OwnerReturn]
public static method ReadAsImage → ()

returns → IImageReader

The IImageReader object.

Reads the samples in this sample buffer as an image.

ReadFromImage


public static method ReadFromImage → (1)

image in : IImageReader

[not-null]
The source image.

Replaces the values in this sample buffer with the pixels read from the given source image.

Both IImageInfo.Width and IImageInfo.Height of image in must be equal to the width and height of this ISampleBuffer object.

IOException

If an I/O error has occurred while reading the image pixels.