Results 1 to 4 of 4

Thread: Creating a QPixmap object from raw image data

  1. #1
    Join Date
    May 2011
    Location
    Germany, Hamburg
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Creating a QPixmap object from raw image data

    Hello Qt centre,
    as the title said I want to create a QPixmap object from an array of raw pixels. I generated this array (it is an apple man^^).
    Can someone help?

    greetings
    eumel1990

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Creating a QPixmap object from raw image data

    You can create QImage from you raw data, using QImage::setPixel(), and then use QImage to create a QPixmap.

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Creating a QPixmap object from raw image data

    There is also QImage constructor that accepts char * data, if you created the data yourself, then you probably know what format does it have (by format I mean the pixel store schema, see here), so you can use this constructor directly, without looping and setting each pixel individually.

  4. The following user says thank you to stampede for this useful post:

    eumel1990 (29th May 2011)

  5. #4
    Join Date
    May 2011
    Location
    Germany, Hamburg
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: Creating a QPixmap object from raw image data

    Hi,
    thanks for your answers.

    That is what I need:
    Qt Code:
    1. QImage ( uchar * data, int width, int height, Format format )
    To copy to clipboard, switch view to plain text mode 

    It's better than setPixel, because I don't have to call the method million times.

    Thanks a lot.

    greetings
    eumel1990

Similar Threads

  1. Replies: 2
    Last Post: 15th March 2010, 10:03
  2. Set the size of a QPixmap object
    By RogerShen in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2010, 10:35
  3. Replies: 2
    Last Post: 29th September 2008, 00:08
  4. Replies: 1
    Last Post: 21st August 2008, 07:44
  5. Saving a QPixmap Object problem
    By StrikerX in forum General Programming
    Replies: 4
    Last Post: 15th November 2007, 02:19

Tags for this Thread

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.