Results 1 to 3 of 3

Thread: const char* QImage Format?

  1. #1
    Join Date
    May 2010
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default const char* QImage Format?

    I'm trying to load an image that has no header to determine type.
    How do I specify what format I want?

    QString path = "..."
    QImage* myVar = new QImage(path, (char *)QImage::Format_RGB32);

    Causes a seg fault

    Please help.

  2. #2
    Join Date
    May 2010
    Posts
    30
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: const char* QImage Format?

    --Solved--

    Here's how I found to make it work:

    QString path = "..."
    QImage* myVar = new QImage(path, "PNG");
    QImage* var2 = myVar->convertToFormat(QImage::Format_RGB32, Qt::ThresholdDither));


    It may look wasteful, but I needed the second copy anyway. For anyone else stuck, there you go.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: const char* QImage Format?

    But this suggests your image has a PNG header... If you have only the raw data, you should use QImage::loadFromData().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Getting const char * from QLineEdit
    By squidge in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2009, 09:28
  2. Connect with const char*
    By grazyna in forum Qt Programming
    Replies: 7
    Last Post: 14th August 2009, 18:13
  3. Cast to const char *
    By brevleq in forum Qt Programming
    Replies: 3
    Last Post: 3rd January 2009, 09:39
  4. char to const char* with atof
    By mickey in forum General Programming
    Replies: 5
    Last Post: 29th February 2008, 04:10
  5. qt_metacast(const char*)
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 3rd September 2007, 07:03

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.