QImage returns wrong bytesPerLine for 8-bit indexed image
Solved
General and Desktop
-
The following code returns wrong number of bytes per line, since it's an 8 bit image, isn't the width supposed to be equal to the bytesPerLine?
It does not happen with all dimensions, but only certain ones.int www = 311; int hhh = 107; QImage nwImg = QImage( dt, www, hhh, QImage::Format_Indexed8 ); const int bpl = nwImg.bytesPerLine(); qDebug() << bpl; qDebug() << www; qDebug() << hhh;
Output
312 311 107
-
@Thrr said in QImage returns wrong bytesPerLine for 8-bit indexed image:
isn't the width supposed to be equal to the bytesPerLine?
Where is this written in the Qt documentation?
It's aligned on a 4 (or 8, don't remember and can't find it atm) byte boundary for performance reasons. This is imo also true für e.g. native windows bitmaps.