split static method
Implementation
static Future<List<Uint8List>> split(ImageParams params) {
// convert image to image from image package
final image = imglib.decodeImage(params.input);
var x = 0, y = 0;
final width = (image!.width / params.size).round();
final height = (image.height / params.size).round();
// split image to parts
final parts = <imglib.Image>[];
for (var i = 0; i < params.size; i++) {
for (var j = 0; j < params.size; j++) {
parts.add(imglib.copyCrop(image, x, y, width, height));
x += width;
}
x = 0;
y += height;
}
// convert image from image package to Image Widget to display
final output = <Uint8List>[];
for (final img in parts) {
final image8List = Uint8List.fromList(imglib.encodeJpg(img));
output.add(image8List);
}
return Future.value(output);
}