【发布时间】:2022-02-02 12:16:26
【问题描述】:
我有一个“销售收据”屏幕,所以我需要使用蓝牙热敏打印机打印,但是当我尝试打印图像时,我只收到一个打印的“黑色”方块。
打印结果(图片只是一个没有背景的logo,所以我也尝试了不同的图片,但没有成功)
使用 blue_thermal_printer 包的代码(我尝试使用其他包,但结果相同)
printContent(BluetoothDevice device) async {
await connectToPrinter(device);
final imageBytes = await imagePathToUint8List('assets/images/logo_ps.png');
await bluetooth.printImageBytes(imageBytes);
await bluetooth.paperCut();
await disconnectToPrinter();
}
Future<Uint8List> imagePathToUint8List(String path) async {
//converting to Uint8List to pass to printer
ByteData data = await rootBundle.load(path);
Uint8List imageBytes =
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
return imageBytes;
}
拜托,谁能告诉我我做错了什么?
【问题讨论】:
标签: flutter dart printing bluetooth thermal-printer