Problem description
I use the ESC * command of the thermal printer to print a picture when it is garbled. The code is modified from C #
Bitmap BT = bitmapfactory.decodefile (mainactivity.path + message), if (BT!=null) {
Mservice.write (Esc_init);
Mservice.write (Esc_standard);
byte[] data = new byte[] {0x1B, 0x33, 0x00};
Mservice.write (data);
Socket. Send (data, data. Length, 0);
Data[0] = 0x00;
DATA[1] = 0x00;
DATA[2] = 0x00; Clear to Zero.
ESC * M NL NH bitmap
byte[] escbmp = new byte[] {0x1B, 0x2A, 0x00, 0x00, 0x00};
int pixelcolor;
ESCBMP[2] = 0x21;
NL, NH
ESCBMP[3] = (byte) (Bt.getwidth ()% 256);
ESCBMP[4] = (byte) (Bt.getwidth ()/256);
Data
for (int i = 0; I < (Bt.getheight ()/+ 1); i++)
{
Mservice.write (escbmp);
for (int j = 0; J < Bt.getwidth (); j + +)
{
for (int k = 0; k <; k++)
{
if ((((i) + K) < Bt.getheight ())//if within the BMP size
{
Pixelcolor = Bt.getpixel (J, (I *) + K);
if (pixelcolor! =-1)
{
DATA[K/8] + = (byte) ( -128 >> (k 8));
DATA[K/8] + = 1;
}
}
}
Mservice.write (data);
Data[0] = 0x00;
DATA[1] = 0x00;
DATA[2] = 0x00; Clear to Zero.
}
Mservice.write (Lf_enter);
Send = Encoding.GetEncoding ("GB18030"). GetBytes ("\ n");
}//Data solution 1
LZ problem ended? Solution 2
I did not solve the tangled ah think of any other ideas. Solutions 3
Can you leave a contact to communicate with us? Solutions 4
There was no result of the communication.
Android Bluetooth print black and white picture ESC command