如何在android下将图像打印到蓝牙热敏打印机上?

lmyy7pcs  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(560)

我正在打印文本和图像。文本打印良好,但图像打印不正确。我用这个代码来打印所有的。

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“是一个图像视图,我从那里得到位图。

有人能帮忙吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题