1
I’m plugging in a printer LX300+II via cable USB directly on a mobile device Android, I can print text normally, as I already have a little bit of printer experience ESC/POS, I tried to adapt a part of the code to print it anyway, unsuccessfully. As if the number of pixels per line were different. Has anyone been there? Follow the code I tried to adapt.
byte[] _data = Base64.decode(logoBase64, Base64.DEFAULT);
Bitmap bmp = BitmapFactory.decodeByteArray(_data, 0, _data.length);
convertBitmap(bmp); //converte as cores para preto.
byte[] rtn = new byte[0];
rtn = concat(rtn , new byte[] {0x1B, 0x33, 24});
int offset = 0;
while (offset < bmp.getHeight()) {
rtn = concat(rtn , new byte[] {0x1B, 0x2A, (byte)33, (byte)255, (byte)3});
for (int x = 0; x < bmp.getWidth(); ++x) {
for (int k = 0; k < 3; ++k) {
byte slice = 0;
for (int b = 0; b < 8; ++b) {
int y = (((offset / 8) + k) * 8) + b;
int i = (y * bmp.getWidth()) + x;
boolean v = false;
if (i < dots.length()) {
v = dots.get(i);
}
slice |= (byte) ((v ? 1 : 0) << (7 - b));
}
rtn = concat(rtn , new byte[] {slice});
}
}
offset += 24;
rtn = concat(rtn , new byte[] {10});
}
return rtn;