Wednesday, April 9, 2014

android Bluetooth printing black and white picture of ESC command


I used thermal printer ESC * Why print command to print the picture is garbled.
Code is modified from the 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 () / 24 + 1); i + +)
{
mService.write (escBmp);
for (int j = 0; j {
for (int k = 0; k <24; k + +)
{
if (((i * 24) + k) {
pixelColor = bt.getPixel (j, (i * 24) + 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
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
lz problem finale yet
Reply:
The reply was deleted administrator at 2013-02-21 11:27:58

Reply:
You are asked to solve it? Not yet.
Reply:
I did not expect to solve the tangled ah, what other ideas do.
Reply:
Can leave a contact exchange with you.
Reply:
exchanges have no results, made about the outcome of trouble

No comments:

Post a Comment