Best way to display live raw RGB data



  • I have a raw image buffer in xRGB format, 4 bytes per pixel, no row padding. I'm unsure as to how to display it on screen - I played around with Qimage, QPixmap and QLabel, but only got blank screens for my efforts :(

    @
    QImage *img = new QImage(_data, _width, _height, QImage::Format_RGB32);

    pix = QPixmap::fromImage(*img);
    ui->lbImage->setPixmap(pix);
    @

    I also tried QImage::Format_ARGB32

    Also, the image buffer is live - I get events detailing rectangles on the image which need redrawing - is there a best (speedy) way to accommodate that?

    For context on my question - the raw buffer is a remote desktop image from a qemu spice server.

    Sorry for my graphics ignorance,

    thanks.


  • Moderators

    Hi,
    First of all what is blank screen? Black, white, transparent(ie. see what is under the label) rectangle?

    Does the input actually contain data? Have you checked?
    If you're using ARGB format make sure your alpha component is not 0 (transparent).
    QImage created this way is only valid as long as the data pointer is valid. Do you pass it around or immediately convert to QPixmap?

    For real speed I would go with OpenGL and a full scene quad with streaming texture.



  • Hi Chris, thanks for the quick reply! You got me onto the right track to.

    bq. Does the input actually contain data? Have you checked?

    I had checked the data, what I hadn't checked was the VM - its power saving had kicked in and blanked the screen :) D'oh!

    Once I woke it up, it was there in all its glory. Though it turned out QImage::Format_RGB32 was the best format to use.

    bq. QImage created this way is only valid as long as the data pointer is valid. Do you pass it around or immediately convert to QPixmap?

    Immediately convert, and then free it. Refreshing the QLabel seems to be all I need to do to update the image.

    Thanks.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.