getIndexImage method
Convert the image
to a palette image.
Implementation
Image getIndexImage(Image image) {
final target = Image(
width: image.width,
height: image.height,
numChannels: 1,
palette: palette);
final ti = target.iterator..moveNext();
target
..frameIndex = image.frameIndex
..frameType = image.frameType
..frameDuration = image.frameDuration;
for (final p in image) {
final t = ti.current;
t[0] = getColorIndex(p);
ti.moveNext();
}
return target;
}