From 8e9971ff652d4f4b468dc3be7e4d7af0ad672352 Mon Sep 17 00:00:00 2001 From: lite1979 Date: Thu, 12 Mar 2020 14:53:59 -0400 Subject: [PATCH] Add U220 image support Adds support for dotDensity 0,1 Closes #10 --- src/qz/printer/ImageWrapper.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qz/printer/ImageWrapper.java b/src/qz/printer/ImageWrapper.java index 6dc34b08a..6c3bede70 100644 --- a/src/qz/printer/ImageWrapper.java +++ b/src/qz/printer/ImageWrapper.java @@ -485,7 +485,9 @@ private void appendEpsonSlices(ByteArrayBuilder builder) { // draw the bitmap in multiple passes, then we'll end up with some // whitespace between slices of the image since the default line // height--how much the printer moves on a newline--is 30 dots. - builder.append(new byte[] {0x1B, 0x33, 24}); + int stripeWidth = dotDensity <=1 ? 1 : 3; + int stripeHeight = dotDensity <= 1 ? 16 : 24; + builder.append(new byte[] {0x1B, 0x33, (byte)stripeHeight }); // OK. So, starting from x = 0, read 24 bits down and send that data // to the printer. The offset variable keeps track of our global 'y' @@ -513,7 +515,7 @@ private void appendEpsonSlices(ByteArrayBuilder builder) { // Remember, 24 dots = 24 bits = 3 bytes. // The 'k' variable keeps track of which of those // three bytes that we're currently scribbling into. - for(int k = 0; k < 3; ++k) { + for(int k = 0; k < stripeWidth; ++k) { byte slice = 0; // A byte is 8 bits. The 'b' variable keeps track @@ -554,7 +556,7 @@ private void appendEpsonSlices(ByteArrayBuilder builder) { // We're done with this 24-dot high pass. Render a newline // to bump the print head down to the next line // and keep on trucking. - offset += 24; + offset += 8 * stripeWidth; builder.append(new byte[] {10}); }