getPaletteFromImage function
Extracts a color palette from an Image object.
Implementation
Future<List<Color>> getPaletteFromImage(
Uint8List imageData,
int colorCount,
int quality,
) async {
final ui.Codec codec = await ui.instantiateImageCodec(imageData);
final ui.FrameInfo frame = await codec.getNextFrame();
final ui.Image uiimage = frame.image;
List<List<int>>? extractedColors = await _decodeImageColors(
uiimage,
colorCount,
quality,
);
if (extractedColors == null) return [];
return extractedColors
.map((rgb) => Color.fromARGB(255, rgb[0], rgb[1], rgb[2]))
.toList();
}