I would say this printer is black and withe (no gray scale). He quote documentation "nW = Number of Bytes to be Printer per line Max: 48 bytes" so I assume one byte is 8 pixels.
probably this is a printer like in cash register (48 pixels per line is to small value to present any useful information).
I agree that he should do conversion to QImage but using format QImage::Format_Mono.
So code would look more or less like this:
Q_ASSSERT(pixmap.depth()==1);
const QImage image
= pixmap.
toImage();
buffer.append('\x1B');
buffer.append('\x23');
int lineSize = (image.width()+7)/8;
buffer.append((char)lineSize);
buffer.append((char)image.hieht());
for(int i=0; i<image.hieht(); ++i)
buffer.append(image.scanLine(i), lineSize);
QFile file("com1:");
// serial port name on device on embedded system (here used Windows CE) return;
file.write(buffer);
file.waitForBytesWritten(3000);// wait max 3 seconds
file.close();
Q_ASSSERT(pixmap.depth()==1);
const QImage image = pixmap.toImage();
QByteArray buffer;
buffer.append('\x1B');
buffer.append('\x23');
int lineSize = (image.width()+7)/8;
buffer.append((char)lineSize);
buffer.append((char)image.hieht());
for(int i=0; i<image.hieht(); ++i)
buffer.append(image.scanLine(i), lineSize);
QFile file("com1:"); // serial port name on device on embedded system (here used Windows CE)
if (!file.open(QIODevice::WriteOnly))
return;
file.write(buffer);
file.waitForBytesWritten(3000);// wait max 3 seconds
file.close();
To copy to clipboard, switch view to plain text mode
Bookmarks