Results 1 to 3 of 3

Thread: get QImage object from buffer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default Re: get QImage object from buffer

    my code:

    Qt Code:
    1. //change 16 bit gray scale to 8 bit gray scale
    2. for(int i=0;i<IMAGE_WIDTH*IMAGE_HEIGHT;i++)
    3. imageBuffer[i]= (*((uint16_t *)(imageBuffer+2*i)))/4;
    4.  
    5. //get QImage object from the buffer, this might be wrong
    6. QImage image(imageBuffer,IMAGE_WIDTH,IMAGE_HEIGHT,QImage::Format_Indexed8);
    7.  
    8. //rescale the image
    9. QImage smallImg=image.scaled(600,300);
    10.  
    11. //use QLabel object to show the image
    12. labelImage->setPixmap(QPixmap::fromImage(smallImg));
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 23rd December 2008 at 22:36.

Similar Threads

  1. QImage buffer
    By rafaelsegundo in forum Qt Programming
    Replies: 3
    Last Post: 24th June 2008, 07:48
  2. How can I save a QImage object into a SQLite3 database table?
    By danielperaza in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2008, 06:39
  3. QShared
    By sabeesh in forum Qt Programming
    Replies: 11
    Last Post: 11th October 2007, 13:40
  4. No output on frame buffer (arm target board)
    By devendra in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 29th November 2006, 21:03
  5. QImage from 8 bit char* RGB buffer
    By tboloo in forum Qt Programming
    Replies: 13
    Last Post: 15th April 2006, 20:56

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.