Results 1 to 3 of 3

Thread: Building a QPixmap using a PNG in RAM

  1. #1
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Building a QPixmap using a PNG in RAM

    Hi! If I have a pointer to a PNG image in RAM (and assuming I know the size of the image), would it be possible to create a QPixmap without having to write the PNG to the HD and then creating it again?
    Thanks!

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building a QPixmap using a PNG in RAM


  3. #3
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    81
    Thanks
    6
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building a QPixmap using a PNG in RAM

    you have the PNG image in RAM. but how is created?

    if you have the image in a QByteArray you can use QPixmap::loadFromData().

    Qt Code:
    1. QPixmap pixmap;
    2. bool isLoaded = pixmap.loadFromData ( byteArray, "PNG", Qt::AutoColor );
    3.  
    4. if ( !isLoaded )
    5. // error
    To copy to clipboard, switch view to plain text mode 

    The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.

Similar Threads

  1. Building on OSX
    By sbauer in forum Newbie
    Replies: 4
    Last Post: 4th September 2009, 14:08
  2. Replies: 4
    Last Post: 28th August 2008, 13:13
  3. Replies: 1
    Last Post: 21st August 2008, 07:44
  4. Replies: 5
    Last Post: 9th April 2007, 14:26
  5. What's faster: QPixmap-to-QImage or QImage-to-QPixmap
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2006, 17:11

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.