I desperately need some help with the following:
- I am using a java program to generate QR Codes, I want to print these QR Codes using the thermal printer.
- I have access, in software, to the BufferedImage as well as the BitMatrix (An array of bits stating which pixels are black or white) object of the QR Code.
I have read the tutorials you have regarding bitmap image printing, as well as QR Code printing but unfortunately these only apply to the use of the Arduino boards and your adafruit library. As I am using java, I cannot use this.
I have managed to print out a qr code using the following set of code:
Code: Select all
static public void BANNED()
{
try
{
// INIT THE PRINTER
System.out.println("Initialising Printer");
outputStream.writeByte(27);
outputStream.writeByte(64);
System.out.println("Matrix Height: " + encoder.getMatrix().getHeight());
System.out.println("Matrix Width: " + encoder.getMatrix().getWidth());
int r = 1;
int n = 48;
for(int x = 384; x > 0; x--)
{
outputStream.writeByte(18); // DC2
outputStream.writeByte(42); // *
outputStream.writeByte(r);
outputStream.writeByte(n);
for(int y = 0; y < 48; y++)
{
/* encoder is the object from a class I use that generates the QR Code image
So here I am using the bit matrix to determine the colour of each pixel*/
if(encoder.getMatrix().get(x/8, y))
{
outputStream.writeByte(255);
//System.out.print(1);
}
else
{
outputStream.writeByte(0);
//System.out.print(0);
}
}
//System.out.println();
}
outputStream.write(10);
outputStream.write(10);
}
catch(IOException e)
{
e.printStackTrace();
}
}
What is the best for doing what I need? Is there some code that can show me what command to send to the printer to get what I desire?
Kind regards,
Dino Alves