You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, August 23rd 2012, 11:09pm

QImage RGB32 problem with loading raw data

I stumbled across a really odd problem (using Qt 4.8.2 on Linux). I am reading raw stream data from a webcam, sent as RGB32 data. The data is 32bit aligned as required by QImage. However, when I load the data, ONLY half the image is filled with data, the rest it set to zero.

After a couple of hours of troubleshooting to no avain. The fact that it only fill 1/2 the QImage buffer is curious, but I don't know why.

Each "frame" is a blob size of 1228800 bytes (width 640 and height 480 pixels).

Source code

1
2
3
4
5
6
7
QImage myImage(myBuff, 640 , 480, QImage::Format_RGB32);

        for (int i=237; i < 243; i++)
        {
            qDebug() << i << "IMAGE #" << myImage.pixel(0, i) << endl;
            qDebug() << i << "BUFFER #" << myBuff[i*640] << endl;
        }


The results are :

237 IMAGE # 987919
237 BUFFER # 44

238 IMAGE # 1250067
238 BUFFER # 16

239 IMAGE # 1447446
239 BUFFER # 16

240 IMAGE # 0
240 BUFFER # 17

241 IMAGE # 0
241 BUFFER # 47

242 IMAGE # 0
242 BUFFER # 16

243 IMAGE # 0
243 BUFFER # 16

As you can see, starting at #240, it becomes zero, but the buffer value is not! I even checked the buffer line by line (to make sure it's 32bit aligned) and that turned out be OK. I also tried with bytesPerLine set to 640*4, but that didn't change anything.

Any idea on what's going on?!!