ColorBuffer
Description
- Derived from
-
SampleBufferInt64 abstract
IBufferCodec
IConfigurable
An implementation of the ISampleBuffer interface that stores diffuse color values.
Each color buffer sample is single 64-bit ARGB color value (see Colors).
The Draw*
methods can be used to perform simple drawing, for example to output debug information or other helpful information during testing.
Public / Constants
ScanlineRangeDefault
The default value of ISampleBuffer.ScanlineRange.
For image coding, the raw pixel value corresponds to the 16-bit color channel value (see Colors).
The default pixel range maps the color channel values 0
and 65535
to 0
resp. 16777215
.
Public / Constructors
Create
Creates a new instance of ColorBuffer.
Instances of ColorBuffer can be pooled by calling IDeletable.Delete.
EncodeDistances
Encodes up to four signed distance buffers into a color buffer (one per color channel).
FromBase85
Decodes a buffer from the given base-85 encoded PXB
file.
- IOException
-
If value in is malformed.
- See also
FromImage
4 overloads
Creates a new instance of ColorBuffer.
- IOException
-
If an I/O error has occurred.
- ValidatingException
-
If the image reader has reported an error, for example because of an unsupported file format feature.
Creates a new instance of ColorBuffer.
- IOException
-
If an I/O error has occurred.
- ValidatingException
-
If the image reader has reported an error, for example because of an unsupported file format feature.
Creates a new instance of ColorBuffer.
- IOException
-
If an I/O error has occurred.
- ValidatingException
-
If the image reader has reported an error, for example because of an unsupported file format feature.
Creates a new instance of ColorBuffer.
- IOException
-
If an I/O error has occurred.
ReadPXB
3 overloads
Reads a pixel buffer in PXB
file format from the given file.
- IOException
-
If an I/O error has occurred while reading file in.
Reads a pixel buffer in PXB
file format from the given data stream.
- IOException
-
If an I/O error has occurred while reading stream in.
Reads a pixel buffer in PXB
file format from the given binary reader.
- IOException
-
If an I/O error has occurred while reading reader in.
Public / Methods
ColorAt
Samples a color value, using linear interpolation.
The sample coordinates (0,0) refer to the top-left corner of the top-left pixel and the sample coordinates (Width,Height) refer to the bottom-right corner of the bottom-right pixel. Sample coordinates will be clamped, if necessary. The center of the top-left pixel lies at sample coordinates (0.5,0.5), which yield the exact same color value as GetPixel for (0,0).
Combine
Combines the given color buffers (first in and second in) using the specified color operation (see ColorOp), storing the results in this buffer.
Downsample
Performs downsampling on the pixels of this color buffer.
Each block of 2x2
input pixels is downsampled to a single output pixel.
+---+---+ | a | b | +---+ +---+---+ => | x | | c | d | +---+ +---+---+
If this color buffer has a width and/or height that is not divisible by two, the right and/or bottom border pixels will be duplicated resp. clipped (see ceiling opt parameter) in order to get a full input pixel block for downsampling. If the output opt buffer is too small, overhang pixels will be discarded. The input and output buffers can be the same.
DrawChar
Draws a character using the famous VGA BIOS font.
The DrawChar method uses the CharacterEncodingSimple.Cp437 character set (yes, this is the one used by VGA BIOS - including the famous frame-building glyphs). The given Unicode character is converted to this character set (if no mapping exist, an ?
will be drawn).
EqualsTolerance
Compares this color buffer with the given one.
This method computes the delta between two colors as the maximum of the absolute of their alpha channels and the color distance computed by Colors.Distance_RGB_RGB, scaled by 65535
and round to the nearest integer.
FromConfigEmbedded
Returns the embedded PXB
file from the given config value.
- ConfigException
-
If value in is invalid.
- IOException
-
If the embedded
PXB
data is invalid.
- See also
HasAlphaPixels
Checks if this color buffer has matching pixels in the given region.
For this method, a matching pixels is defined as a pixel that has an alpha value which is greater than or equal to alphaMin opt and less than or equal to alphaMax opt. The default parameter values check for the presence of pixels that are not fully opaque.
PadColor
Resizes this color buffer to the given size by padding the right and bottom edges with the specified color.
- See also
PadEdges
Resizes this color buffer to the given size by duplicating the right and bottom edges.
- See also
ReadPXBInfo
3 overloads
Reads a pixel buffer in PXB
file format from the given file.
- IOException
-
If an I/O error has occurred while reading from file in.
Reads a pixel buffer in PXB
file format from the given data stream.
- IOException
-
If an I/O error has occurred while reading from stream in.
Reads a pixel buffer in PXB
file format from the given binary reader.
- IOException
-
If an I/O error has occurred while reading from reader in.
SetScanlineFormat
Specifies the pixel format to use for encoding buffer samples.
If format opt is set to PixelFormat.Unknown, the pixel format will be determined from the color values in the buffer. Once set, the format opt will hint all subsequent encoding / decoding steps. To avoid unintended side-effects, the format opt should be reset to PixelFormat.Unknown as soon as possible.
- See also
Trim
2 overloads
Trims the edges of this buffer by removing all rows and columns that contain fully transparent pixels only.
Trims the edges of this buffer by removing all rows and columns that contain fully transparent pixels only.
WriteImage
Writes the pixel data in this buffer to the given file, using default writer options.
This method obtains an IImageWriter via ImageFormat.WriteImage of ImageFormat.Any and then calls IImageWriter.WriteImage, passing the result of ISampleBuffer.ReadAsImage on this
sample buffer.
- IOException
-
If an I/O error has occurred while writing to file in.
WritePXB
3 overloads
Writes the pixel data in this buffer to the given file, using the PXB
file format.
- IOException
-
If an I/O error has occurred while writing to file in.
Writes the pixel data in this buffer to the given binary data stream, using the PXB
file format.
- IOException
-
If an I/O error has occurred while writing to stream in.
Writes the pixel data in this buffer to the given binary writer, using the PXB
file format.
- IOException
-
If an I/O error has occurred while writing to writer in.
WriteTXB
Writes the texel data in this buffer to the given file, using the TXB
file format.
- IOException
-
If an I/O error has occurred while writing to file in.