从 Android 中的热敏蓝牙打印机打印的图像中删除线条

Remove Lines From Image Printed From Thermal Bluetooth Printer In 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);

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

baos.write(SET_LINE_SPACING_30);

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