diff --git a/app/src/main/java/com/dantsu/thermalprinter/MainActivity.java b/app/src/main/java/com/dantsu/thermalprinter/MainActivity.java
index b0647ed..7dbbcea 100644
--- a/app/src/main/java/com/dantsu/thermalprinter/MainActivity.java
+++ b/app/src/main/java/com/dantsu/thermalprinter/MainActivity.java
@@ -266,7 +266,7 @@ public AsyncEscPosPrinter getAsyncEscPosPrinter(DeviceConnection printerConnecti
"[L]Tel : +33801201456\n" +
"[L]\n" +
"[C]831254784551\n" +
- "[C]http://www.developpeur-web.dantsu.com/"
+ "[C]http://www.developpeur-web.dantsu.com/\n"
);
}
}
diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/EscPosPrinterCommands.java b/escposprinter/src/main/java/com/dantsu/escposprinter/EscPosPrinterCommands.java
index 5fe903b..7bb3549 100644
--- a/escposprinter/src/main/java/com/dantsu/escposprinter/EscPosPrinterCommands.java
+++ b/escposprinter/src/main/java/com/dantsu/escposprinter/EscPosPrinterCommands.java
@@ -61,9 +61,15 @@ public class EscPosPrinterCommands {
private EscPosCharsetEncoding charsetEncoding;
- private static byte[] initImageCommand(int bytesByLine, int bitmapHeight) {
+ public static byte[] initImageCommand(int bytesByLine, int bitmapHeight) {
+ int
+ xH = bytesByLine / 256,
+ xL = bytesByLine - (xH * 256),
+ yH = bitmapHeight / 256,
+ yL = bitmapHeight - (yH * 256);
+
byte[] imageBytes = new byte[8 + bytesByLine * bitmapHeight];
- System.arraycopy(new byte[]{0x1D, 0x76, 0x30, 0x00, (byte) bytesByLine, 0x00, (byte) bitmapHeight, 0x00}, 0, imageBytes, 0, 8);
+ System.arraycopy(new byte[]{0x1D, 0x76, 0x30, 0x00, (byte) xL, (byte) xH, (byte) yL, (byte) yH}, 0, imageBytes, 0, 8);
return imageBytes;
}
diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParserImg.java b/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParserImg.java
index cd28bea..252b796 100644
--- a/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParserImg.java
+++ b/escposprinter/src/main/java/com/dantsu/escposprinter/textparser/PrinterTextParserImg.java
@@ -106,9 +106,10 @@ public PrinterTextParserImg(PrinterTextParserColumn printerTextParserColumn, Str
public PrinterTextParserImg(PrinterTextParserColumn printerTextParserColumn, String textAlign, byte[] image) {
EscPosPrinter printer = printerTextParserColumn.getLine().getTextParser().getPrinter();
- int byteWidth = ((int) image[4] & 0xFF),
+ int
+ byteWidth = ((int) image[4] & 0xFF) + ((int) image[5] & 0xFF) * 256,
width = byteWidth * 8,
- height = ((int) image[6] & 0xFF),
+ height = ((int) image[6] & 0xFF) + ((int) image[7] & 0xFF) * 256,
nbrByteDiff = (int) Math.floor(((float) (printer.getPrinterWidthPx() - width)) / 8f),
nbrWhiteByteToInsert = 0;
@@ -123,16 +124,14 @@ public PrinterTextParserImg(PrinterTextParserColumn printerTextParserColumn, Str
if (nbrWhiteByteToInsert > 0) {
int newByteWidth = byteWidth + nbrWhiteByteToInsert;
- byte[] newImage = new byte[newByteWidth * height + 8];
- System.arraycopy(image, 0, newImage, 0, 8);
- newImage[4] = (byte) newByteWidth;
+ byte[] newImage = EscPosPrinterCommands.initImageCommand(newByteWidth, height);
for (int i = 0; i < height; i++) {
System.arraycopy(image, (byteWidth * i + 8), newImage, (newByteWidth * i + nbrWhiteByteToInsert + 8), byteWidth);
}
image = newImage;
}
- this.length = (int) Math.ceil(((float) (((int) image[4] & 0xFF) * 8)) / ((float) printer.getPrinterCharSizeWidthPx()));
+ this.length = (int) Math.ceil(((float) byteWidth * 8) / ((float) printer.getPrinterCharSizeWidthPx()));
this.image = image;
}