I have an app that can print tickets with Thermal Printers using ESC POS language. The code I'm using right now is:
/* <-40char-> */
Socket sock = new Socket(Impresora.getImpresora_Tickets().getIp(), Impresora.getImpresora_Tickets().getPuerto());
OutputStreamWriter osw = new OutputStreamWriter(sock.getOutputStream(), Charset.forName("CP1252"));
PrintWriter oStream = new PrintWriter(osw);
/*Start*/
for(int i = 0; i<Impresora.getImpresora_Tickets().getInic().size(); i++)
oStream.print(Impresora.getImpresora_Tickets().getInic().get(i));
/*Set Font Size*/
for(int i = 0; i<Impresora.getImpresora_Tickets().getLetra4().size(); i++)
oStream.print(Impresora.getImpresora_Tickets().getLetra4().get(i));
oStream.println("HELLO WORLD");
And it works fine. The thing is that now I'm capturing the user's signature with the tablet and I want to print it in the end of the ticket. I have it as a bitmap object but I don't know how to send it to the printer. Can someone help me? Thanks!
EDIT 1:
I'm trying to do something but I think I'm not going in the right way...
/**
* Redimensionar imagen
*/
Bitmap firma = Current_Mesa.getT().getFirma_credito();
firma = Bitmap.createScaledBitmap(firma, 255, 64, false);
/**
* Print imagen
*/
ByteArrayOutputStream stream = new ByteArrayOutputStream();
firma.compress(CompressFormat.JPEG, 70, stream);
byte[] firma_bytes = stream.toByteArray();
byte[] SELECT_BIT_IMAGE_MODE = {0x1B, 0x2A, 33};
byte[] SET_LINE_SPACE_24 = {0x1B, 0x33, 24};
byte[] PRINT_AND_FEED_PAPER = new byte[]{0x0A};
for(byte b : SELECT_BIT_IMAGE_MODE)
oStream.print((char)b);
for(byte b : SET_LINE_SPACE_24)
oStream.print((char)b);
for(int i = 0; i < firma_bytes.length; i+=8)
{
for(int plus = 0; plus < 8; plus++)
oStream.print(firma_bytes[i+plus]);
for(byte b : PRINT_AND_FEED_PAPER)
oStream.print((char)b);
}