如何将图像打印到 Android 中的蓝牙热敏打印机?

问题描述

我正在打印文本和图像。文本打印正常,但图像打印不正确。我正在使用此代码打印所有内容

    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,0);
    printNewLine();
    printPhoto();
    printNewLine();
    printCustom(token,0);
    printNewLine();
    printCustom(checkInTime,0);
    printNewLine();
    printCustom(poweredBy,0);
    printNewLine();
    printCustom(appName,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”是我从那里获取位图的图像视图。

enter image description here

有人可以帮忙吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)