All data are in fact binary stored as a series of bytes. So there is no need to convert to hex or
unsigned char
array if you have the data in a buffer because an
unsigned char
is a byte.
If you want to print a PNG image with Qt use
QImage
to load the file and paint with
QPainter
on a
QPrinter
:
QPrinter printer(QPrinterInfo::defaultPrinter());
QPrintDialog *dlg = new QPrintDialog(&printer, 0);
int res = dlg->exec();
delete dlg;
if (res != QDialog::Accepted)
return;
QString fileName = "/usr/share/pixmaps/ravi.jpg/png";
QImage img(fileName);
QPainter painter(&printer);
painter.drawImage(QPoint(0,0), img);
painter.end();
[EDIT]
There is a potentially error in your code regarding the number of bytes to be processed:
int CPrinter::prepare_bmp(unsigned char *bmpbuf,unsigned char *data,int len);
len=prepare_bmp((unsigned char*)bmpbuff,visb_bmp,sizeof(visb_bmp));
When
visb_bmp
is not an array of fixed size (not
unsigned char visb_bmp[VISB_SIZE];
) but a pointer to allocated memory,
sizeof(visb_bmp)
is the size of a pointer which is 4 or 8 depending on the build mode (32 or 64 bit).
[/EDIT]