Android Bluetooth print black and white picture ESC command

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.