我正在打印文本和图像。文本打印良好,但图像打印不正确。我用这个代码来打印所有的。
private void printTokenTest() {
String line = "---------------------------";
String agentName = AppSettings.getString(AppSettings.name);
String token = "Token Number: " + tokenNumber;
String checkInTime = "Check In Time: " + checkInDateTime;
String poweredBy = "Powered by";
String appName = "Dummy\n\n\n";
printCustom(AppSettings.getString(AppSettings.name), 2, 0);
printNewLine();
printCustom(line, 1, 0);
printNewLine();
printCustom(agentName, 2, 0);
printNewLine();
printPhoto();
printNewLine();
printCustom(token, 0, 0);
printNewLine();
printCustom(checkInTime, 0, 0);
printNewLine();
printCustom(poweredBy, 0, 0);
printNewLine();
printCustom(appName, 0, 1);
printNewLine();
mService.sendMessage("", "GBK");
}
public void printPhoto() {
try {
byte[] command = AppUtils.decodeBitmap(AppUtils.getScreenShotBitmap(ivQRCode));
mService.write(PrinterCommands.ESC_ALIGN_CENTER);
printText(command);
} catch (Exception e) {
e.printStackTrace();
Log.e("PrintTools", "the file isn't exists");
}
}
//print byte[]
private void printText(byte[] msg) {
// Print normal text
mService.write(msg);
}
但它打印的图像是这样的。”ivqrcode“是一个图像视图,我从那里得到位图。
有人能帮忙吗?
暂无答案!
目前还没有任何答案,快来回答吧!