Results 1 to 5 of 5

Thread: Error when Loading QImage

  1. #1
    Join Date
    Apr 2024
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Error when Loading QImage

    My program crashes when I try to load an image from my computer into a QImage. I made sure that the path to the file is correct and tried to make a QImage pointer, but it still results in an error. This was originally part of a larger program, but even in this simple recreation, it doesn't work.

    Here is my code in main.cpp:

    Qt Code:
    1. #include "mainwindow.h"
    2.  
    3. #include <QApplication>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. MainWindow w;
    9. QImage test;
    10. test.load("C:/IMAGES/IMAGE.png"); // crashes program
    11. w.show();
    12. return a.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    Here is the error received when I used the debugger:

    qt.gui.imageio: libpng warning: iCCP: known incorrect sRGB profile
    HEAP[sdf.exe]:
    Invalid address specified to RtlFreeHeap( 00000000000D0000, 0000000000DF7240 )

    There are also no changes in mainwindow.cpp and the header file, but I added "CONFIG += console" to the .pro file.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    517
    Thanks
    12
    Thanked 77 Times in 75 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Error when Loading QImage

    Hi, is the image a valid .png file? How large is it? Have you tried other .png files?

    Ginsengelf

  3. #3
    Join Date
    Nov 2024
    Posts
    2
    Qt products
    Qt5

    Default Re: Error when Loading QImage

    The error you are getting may be due to the Qt platform lacking a plugin for the format you are trying to use, or the image path may be incorrect or the image may be corrupted. Check for file path errors.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,304
    Thanks
    313
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Error when Loading QImage

    PNG format support is built in to Qt; it does not require a plugin. And since the OP's example provides an absolute path to the image file, a path error is probably not the cause. I would suspect a corrupted image.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Nov 2024
    Posts
    1
    Qt products
    Qt5
    Platforms
    Android

    Default Re: Error when Loading QImage

    Quote Originally Posted by ReginaldLarson View Post
    The error you are getting may be due to the Qt platform lacking a plugin for the format you are trying to use, or the image path may be incorrect or the image may be corrupted. Check for file path errors.
    thank you

Similar Threads

  1. loadFromData() of QImage -crash in case of .gif loading
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2011, 12:56
  2. Loading an Image into QImage
    By jstippey in forum Qt Programming
    Replies: 5
    Last Post: 4th January 2011, 15:36
  3. Loading corrupt jpeg images with QImage
    By mikeee7 in forum Qt Programming
    Replies: 15
    Last Post: 3rd December 2010, 02:59
  4. Loading a raw image into QImage
    By Luc4 in forum Qt Programming
    Replies: 6
    Last Post: 16th May 2010, 16:20
  5. QImage not loading successively.
    By node_ex in forum Qt Programming
    Replies: 3
    Last Post: 26th July 2008, 14:20

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
  •  
Qt is a trademark of The Qt Company.