IndexedFormat<P>.bits16 constructor
- Iterable<
P> palette, { - required PixelFormat<
P, void> format, - String? name,
- int? zero,
- int? max,
Creates an 16-bit indexed pixel format with the given palette
.
The format
is used to convert between the palette colors and the
indexed values.
The zero
and max
values are used to clamp the indexed values to the
valid range of the palette; if omitted, they default to 0
and
palette.length - 1
respectively.
Implementation
factory IndexedFormat.bits16(
Iterable<P> palette, {
required PixelFormat<P, void> format,
String? name,
int? zero,
int? max,
}) {
if (palette.length > 65536) {
throw ArgumentError.value(
palette.length,
'palette.length',
'Must be less than or equal to 65536 for 16-bit indexed format.',
);
}
return IndexedFormat._(
List.of(palette),
format,
zero: zero ?? 0,
max: max ?? palette.length - 1,
bytesPerPixel: 2,
name: name ?? 'INDEXED_${format.name}_${palette.length}',
);
}