【问题标题】:Remove Lines From Image Printed From Thermal Bluetooth Printer In Android从 Android 中的热敏蓝牙打印机打印的图像中删除线条
【发布时间】:2021-07-21 00:34:50
【问题描述】:

我正在通过 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);

【问题讨论】:

    标签: android thermal-printer


    【解决方案1】:

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

    baos.write(SET_LINE_SPACING_30);
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-28
      • 2013-06-03
      • 2013-11-11
      • 2019-08-27
      • 2019-11-23
      • 2019-01-27
      • 1970-01-01
      相关资源
      最近更新 更多