Results 1 to 3 of 3

Thread: Creating a Pixmap out of an array of data

  1. #1
    Join Date
    Feb 2007
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Creating a Pixmap out of an array of data

    Hi

    I have my picture data on an array (unsigned char array, three chars per pixel) and I want to create a Pixmap to display it. How can I do that?

    On the other hand, what's the fastest way to display bitmaps? Cause I'm using QLabel now, but I don't think that's the better way.

    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating a Pixmap out of an array of data

    Use QPixmap::loadFromData( const uchar*, ... ).

    As for the fastest way, that depends on what you need to do.
    If you display only one image at a time, then QLabe is OK.
    If you have more images, then you should switch to QGraphicsView.

    Regards

  3. #3
    Join Date
    Feb 2007
    Posts
    13
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Creating a Pixmap out of an array of data

    Thanks!

    I tried that method but I get a valid Pixmap but without the right info. I just get a black picture. Do I have to specify any format?
    Just to let you know, that what I have:

    on header file:
    unsigned char rgbdata[352 * 288 * 3];
    QPixmap pixmap;
    ...

    on constructor:
    pixmap = QPixmap(width,height);
    ...
    to display, after getting the data:
    if(pixmap.loadFromData(rgbdata,352*288*3))
    pixmap.save("test.jpg");



    Thanks!

Similar Threads

  1. Creating a QImage from uchar* data
    By forrestfsu in forum Qt Programming
    Replies: 6
    Last Post: 8th February 2007, 15:21
  2. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  3. Creating a global array in my code???
    By therealjag in forum General Programming
    Replies: 5
    Last Post: 13th March 2006, 11:13

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.