I have a monochromatic image displayed on a QLabel, and I would like to save the image in a plain byte array. The code is the following:
QLabel *label;
label = new QLabel(this);
...
QPixmap pixmap = label->grab();
QImage image = pixmap.toImage();
QImage binaryImage = image.convertToFormat(QImage::Format_Mono);
const uchar* imageData = binaryImage.constBits();
The size of imageData should be: widht * height / 8, as each pixel is represented by one bit, and all bits are organized in bytes. Anyway I don't understand how data are saved in imageData.
If I plot the array content assuming that the image is saved line by line, I don't get the original image.