Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
5.9.1
-
None
-
My spec: MS Win 7x64, Qt 5.9.1 mingw
Description
I have found that if I have load QImage it is always in QImage::Format_RGB32 (even if on disk images are stored with 24 bit depth). But I need Format_RGB888. So I call QImage::convertToFormat. Images are converted but some of them get some extra bytes and look distorted.
Code to reproduce:
QImage _qimg; _qimg.load("filename.jpg"); QImage _tmpqimg; if(_qimg.format() == QImage::Format_Grayscale8) { _tmpqimg = _qimg; } else { _tmpqimg = std::move(_qimg.convertToFormat(QImage::Format_RGB888)); } std::cout << _tmpqimg.depth() << " bits" << " W:" << _tmpqimg.width() << " H:" << _tmpqimg.height() << std::endl; std::cout << "byteCount(): " << _tmpqimg.byteCount() << ";\twidth() x height() x depth()/8: " << _tmpqimg.width() * _tmpqimg.height() * _tmpqimg.depth()/8 << ";\tdiff: " << _tmpqimg.byteCount() - _tmpqimg.width() * _tmpqimg.height() * _tmpqimg.depth()/8 << std::endl << std::endl;
I also have found that difference of byteCount() and (width() x height() x depth()/8) is always K times height(), where K could be 0,1,2,3