Class IndexedImage
- Namespace
- Egami.Quantization
- Assembly
- Egami.dll
An image as palette indices: one byte per pixel and the palette they index, for formats and APIs that want indexed color, such as a PDF indexed image. The indices are pooled; dispose the image to return them.
public sealed class IndexedImage : IDisposable
- Inheritance
-
IndexedImage
- Implements
- Inherited Members
Examples
// Indices plus palette, for a PDF indexed-color image or a format of your own.
using IndexedImage indexed = photo.ToIndexed(new PaletteOptions { MaxColors = 64 });
byte[] lookup = [.. indexed.Palette.Colors.SelectMany(c => new[] { c.R, c.G, c.B })];
byte[] samples = indexed.Indices.ToArray();
Properties
Height
Gets the height in pixels.
public int Height { get; }
Property Value
Indices
Gets every index, row after row, Width per row.
public ReadOnlySpan<byte> Indices { get; }
Property Value
Exceptions
- ObjectDisposedException
The image has been disposed.
Palette
Gets the palette the indices refer to.
public Palette Palette { get; }
Property Value
Width
Gets the width in pixels.
public int Width { get; }
Property Value
Methods
Dispose()
Returns the pooled indices.
public void Dispose()
Row(int)
Returns the indices of one row.
public ReadOnlySpan<byte> Row(int y)
Parameters
yintThe row.
Returns
- ReadOnlySpan<byte>
The row's Width indices.
Exceptions
- ArgumentOutOfRangeException
yis outside the image.- ObjectDisposedException
The image has been disposed.