Results 1 to 3 of 3

Thread: QImage crash when the format is "Format_Indexed8"

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QImage crash when the format is "Format_Indexed8"

    os : win7 64bits
    compiler : mingw4.6.2
    qt version : qt4.8.1(the dll and and the lib haven't rebuild by mingw4.6.2)

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QtGui/QImage>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7.  
    8. QImage src("../GIL_with_Qt/images_00/lena/lena.jpg");
    9. src = src.convertToFormat(QImage::Format(3) );
    10. QImage dst(src.size(), src.format());
    11.  
    12. dst.save("E:/lena/lena_Format_Indexed8.jpg");
    13. return a.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    This will cause the program crash, what kind of mistake do I make?
    Thank you very much
    Attached Images Attached Images

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QImage crash when the format is "Format_Indexed8"

    Crashes here too but it doesn't do anything useful as far as I can see.

    You load a full colour JPEG image, ask Qt to convert it to a palette-base image, create an uninitialised blank image of the same size and format and attempt to save that as a JPEG file. Attempting to save that new image is causing the crash: JPEG is not a good storage for a 8-bit indexed image although it should not crash. Saving as PNG does not crash but does not do what I think you are expecting. If you want to save the converted image then you do not need dst at all: just save src.

    BTW: You should use QImage::Format enum constants rather than an integer magic number, e.g. QImage::Format_Indexed8 rather than 3.

  3. #3
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QImage crash when the format is "Format_Indexed8"

    Thanks for your reply, I know it didn't do anything useful of my codes snippet,
    I only post the part of the codes which make it crash.I use magic number instead
    of QImage::Format_* because I need to iterate through the format in my original
    codes.

    Is this a bug?Should I report it?If I should, where is the right place to report?
    Thanks a lot.

Similar Threads

  1. Replies: 0
    Last Post: 21st September 2011, 18:59
  2. QProgressBar "crash" - doesn't work properly
    By metRo_ in forum Qt Programming
    Replies: 6
    Last Post: 23rd October 2010, 13:56
  3. QImage::scaled cause "raster"/"grid"
    By wesley in forum Qt Programming
    Replies: 24
    Last Post: 26th April 2010, 09:42
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. QDrag setPixmap failed with "XBM" format
    By alfa_wu in forum Qt Programming
    Replies: 2
    Last Post: 2nd May 2007, 02:32

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.