clause method
CommandClause
clause(
)
override
Implementation
@override
CommandClause clause() {
var processer = Pbita(
command: 'tspl',
threshold: _threshold,
compress: _compress,
reverse: _reverse,
);
var info = processer.processWithBytes(Uint8List.fromList(_image));
var fimage = info.result;
if (fimage == null) {
throw Exception('Wrong image data');
}
int width = fimage.width;
int height = fimage.height;
int byteWidth = ((width % 8 == 0) ? (width / 8) : (width / 8 + 1)).floor();
Commander commander = Commander.make();
TSPLCommand tsplCommand = TSPLCommand(header: header())
.appendNumber(_x)
.appendNumber(_y)
.appendNumber(byteWidth)
.appendNumber(height);
if (_compress) {
tsplCommand.appendText("3").appendNumber(fimage.data.length);
commander
.pushClause(tsplCommand.clause(), newline: false)
.pushText(",", newline: false)
.pushBinary(fimage.data, newline: false);
} else {
tsplCommand.appendNumber(_mode.getMode());
commander
.pushClause(tsplCommand.clause(), newline: false)
.pushText(",", newline: false)
.pushBinary(fimage.data, newline: false);
}
Command command = commander.newline().command();
return Raw.binary(command.binary()).clause();
}