Results 1 to 6 of 6

Thread: how can I get picture data from file ?

  1. #1
    Join Date
    Jul 2008
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default how can I get picture data from file ?

    hi ,I write picture data to file by QDataStream,and I want get the picture data from the file as 'char*' 。

    How can I do this? thansk!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how can I get picture data from file ?

    take a look at QImage::fromData.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jul 2008
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how can I get picture data from file ?

    thanks !
    I have got QImage object! I want to known than how to convert QImage to char*?

    example:
    I want a function like this:
    char* readimage(QString filepath); // I don't know how to convert QImage to char*!

    this is ok .I have already got QImage from file.
    QImage readimage(QString filepath); //

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how can I get picture data from file ?

    there is an example in Qt Assistant (take a look at description of 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 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    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 can I get picture data from file ?

    May be QImage::bits might help you

  6. #6
    Join Date
    Jul 2008
    Posts
    33
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how can I get picture data from file ?

    thanks !
    the problem was fixed!

Similar Threads

  1. Check for invalid file name in QFileDialog
    By darren in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2008, 14:43
  2. Getting sound data from a wave file
    By ko9 in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2007, 11:23
  3. file renaming on windows
    By jdd81 in forum Qt Programming
    Replies: 9
    Last Post: 2nd October 2007, 19:41
  4. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 15:21
  5. How To Extract A File
    By deekayt in forum General Programming
    Replies: 7
    Last Post: 5th December 2006, 18:27

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.