Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.6.3, 5.12.0, 5.12.4
-
None
Description
QImage can't handle correctly grayscale buffers for some widths/heights. In this case, 2 bytes are skipped at the end of each line, resulting in a tearing like effect:
(at 450x450)
The expected result was:
(at 900x900)
My test code was:
#include <QImage> int main(int argc, char *argv[]) { int w=450, h=450; int hW=w*.5; QByteArray buff(w*h, Qt::Uninitialized); for(int y=0; y<h; ++y) { std::memset((uchar*)&buff.data()[y*w], 0, hW); std::memset((uchar*)&buff.data()[y*w+hW], 255, hW); } QImage((uchar*) buff.data(), w, h, QImage::Format_Grayscale8).save("result.jpg"); }