android - 从 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 点或接近它。
如果它不是正确的高度,请尝试不同的值。
推荐阅读
- visual-studio-code - 有没有办法让活动标签边框在顶部而不是底部突出显示?
- charts - 问题与图表 JS 中的数据有关
- python - python代码后端和flutter之间的链接
- python - 如何根据我以前的类别在 pandas 数据框中创建一个新类别?
- c - C中的错误常量值
- python - Python (2.7) - 考虑多个字段的简单 IF THEN 逻辑
- javascript - 将对象从数组 A 移动到数组 B. Ramda.js
- sql - 计算不同表中的行数并按特定条件分组
- html - 尽管没有填充,但 Div 空间
- python - 如何使用 Python 将新列附加到 csv?