image method
Implementation
@override
Future<bool> image(Uint8List image, {int threshold = 150}) async {
final decodedImage = img.decodeImage(image)!;
final rasterizeImage = _toRaster(decodedImage, dpi: int.parse(dpi));
final converted = toPixel(ImageData(width: decodedImage.width, height: decodedImage.height),
paperWidth: int.parse(_sizeWidth), dpi: int.parse(dpi), isTspl: true);
final ms = 1000 + (converted.height * 0.5).toInt();
return await sendToConnector(() {
if (image.length > 0) {
List<int> buffer = [];
buffer += this._config.codeUnits;
buffer += Command.clearCache().codeUnits;
buffer += Command.imageString('0', '0', converted.width.toString(), converted.height.toString(), mode: '0').codeUnits;
buffer += rasterizeImage.data;
buffer += Command.EOL_HEX;
buffer += Command.printIt('1', repeat: '1').codeUnits;
buffer += Command.close().codeUnits;
return buffer;
} else {
return [];
}
}, delayMs: ms);
}