首页 > 解决方案 > 从 Android 中的热敏蓝牙打印机打印的图像中删除线条

问题描述

我正在通过 Android 应用程序中的热敏蓝牙打印机在收据中打印图像。问题是线条通过图像显示。我怎样才能删除线?图片嵌入在下面

线条通过二维码显示

我使用的代码如下所示

    int lineWidth = 384;

    int size0NoEmphasizeLineWidth = 320 / 8; //line width / font width
    String singleLine = "";
    String singleLine2 = "";
    int size0NoEmphasizeLineWidth2 =200 / 5;
    for(int i = 0; i < size0NoEmphasizeLineWidth; ++i) {
        singleLine += "-";
    }
    for(int i = 0; i < size0NoEmphasizeLineWidth2; ++i) {
        singleLine2 += "-";
    }
    String doubleLine = "";
    for(int i = 0; i < size0NoEmphasizeLineWidth; ++i) {
        doubleLine += "=";
    }

    int id = R.drawable.qrcode;
    Bitmap logoBitmap = BitmapFactory.decodeResource(context.getResources(),id);
    int logoTargetWidth =150;
    byte[] d1 = convertBitmap(logoBitmap, logoTargetWidth, 150);


    try {
        OutputStream baos = mBluetoothSocket.getOutputStream();
        baos.write(INIT);
        baos.write(POWER_ON);
        baos.write(NEW_LINE);
        baos.write(ALIGN_CENTER);
        baos.write(SELECT_BIT_IMAGE_MODE);
        baos.write(PrinterCommandsAlgon.FEED_LINE);
        baos.write(SET_LINE_SPACING_30);

        for(int j = 0; j < d1.length / logoTargetWidth; ++j) {
         baos.write(hexToByteArray("1B2A00"));
         baos.write((byte)logoTargetWidth);
         baos.write((byte)(logoTargetWidth >> 8));
         byte[] temp = new byte[logoTargetWidth];
         System.arraycopy(d1, j * logoTargetWidth, temp, 0, temp.length);
         baos.write(temp);
         baos.write(NEW_LINE);
         }

        baos.write(NEW_LINE);
        baos.write(CHAR_SPACING_0);

        baos.write(FONT_SIZE_0);
       
          baos.write(NEW_LINE);

标签: androidthermal-printer

解决方案


可能是因为行距设置为 30 点。

baos.write(SET_LINE_SPACING_30);

请尝试将您设置的值更改为 24 点或接近它。
如果它不是正确的高度,请尝试不同的值。


推荐阅读