Results 1 to 5 of 5

Thread: How to get the content of a QImage ?

  1. #1
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default How to get the content of a QImage ?

    Hi there!

    I'd like to get the data of a QImage or a QPixmap


    Any idea

  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: How to get the content of a QImage ?

    What do you mean by data of image ?
    QImage::bits ?

  3. #3
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default Re: How to get the content of a QImage ?

    I mean the data that you can see when you open an image with notepad for example.


    Maybe a buffer could help ?

  4. #4
    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: How to get the content of a QImage ?

    Have a look at QImage::save
    Qt Code:
    1. QImage image;
    2. QBuffer buffer(&ba);
    3. buffer.open(QIODevice::WriteOnly);
    4. image.save(&buffer, "PNG"); // writes image into ba in PNG format
    To copy to clipboard, switch view to plain text mode 
    So may be the bytearray ba might of use to you

  5. #5
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default Re: How to get the content of a QImage ?

    Thank you that's a good step forward !

    Now I can send the datas of an image to a browser.

    However, the files (png) are still corrupted according to all my softwares (photoshop, paint, windows, ...)

    Why is that ?


    EDIT : I just found out ! In fact, I used utf8 instead of ISO 8859-1 for my QTextStream !

    Thanks again aamer4yu !
    Last edited by fitzy; 29th October 2009 at 15:53.

Similar Threads

  1. Replies: 12
    Last Post: 7th September 2011, 16:37
  2. QImage internal error
    By GiuseppeBonfa in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2009, 14:12
  3. Streaming QImage (QByteArray, QDataStream, QBuffer)
    By knarz in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2009, 22:05
  4. Saving QLabel content in a file
    By Caius Aérobus in forum Newbie
    Replies: 1
    Last Post: 29th October 2008, 17:03
  5. Multiple QPainters on QImage
    By fire in forum Qt Programming
    Replies: 3
    Last Post: 14th August 2008, 13:10

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.