Results 1 to 3 of 3

Thread: Problem in displaying RGB32 data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Problem in displaying RGB32 data

    Qt Code:
    1. void Custom_window::display()
    2. {
    3. if(i<5){
    4. printf("\n Calling Capture function\n");
    5. uchar* data = (uchar*)function(); //data is in bgr32 bit format
    6. QPixmap *p;
    7. // Frame display
    8. image = new QImage(data,640,480,QImage::Format_RGB32);
    9. label->setPixmap(p->fromImage(*image));
    10. textmessage->append("The path of the file is");
    11. i++;
    12. }
    13. else
    14. i=0;
    15. }
    To copy to clipboard, switch view to plain text mode 
    Unable to display the image. Need help
    Last edited by marcel; 16th June 2008 at 18:54.

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem in displaying RGB32 data

    Your code is basically correct, although you could change it to:
    Qt Code:
    1. uchar* data = (uchar*)function(); //data is in bgr32 bit format
    2. // Frame display
    3. QImage image(data, 640, 480, QImage::Format_RGB32);
    4. label->setPixmap(QPixmap::fromImage(image));
    To copy to clipboard, switch view to plain text mode 
    Of course you have to be certain that function() returns a pointer to 640*480*4 bytes of data which remain valid until after setPixmap has been called.

    So, what do you see? is anything displayed?

  3. #3
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem in displaying RGB32 data

    Sorry, but I just realized that the above code needs data to remain valid for a longer time.
    A safer way would be to copy the image data.
    Qt Code:
    1. QImage image(640, 480, QImage::Format_RGB32);
    2. memcpy(image.bits(), data, 640*480*4);
    3. label->setPixmap(QPixmap::fromImage(image));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 7
    Last Post: 15th January 2008, 14:40
  2. Displaying data in QTable
    By raghvendramisra in forum Qt Tools
    Replies: 1
    Last Post: 6th September 2007, 12:48
  3. Table Model / View Problem -- Data Not Displaying
    By jhendersen in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2007, 06:45
  4. problem with reading input data in qt
    By Ahmad in forum Qt Programming
    Replies: 3
    Last Post: 9th April 2007, 10:58
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.