Results 1 to 12 of 12

Thread: loadFromData() of QImage crash in case of .gif loading

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: loadFromData() of QImage crash in case of .gif loading

    Quote Originally Posted by santosh.kumar View Post
    Am i doing something wrong....But how we use this in loadFromData().
    because image.loadFromData() is crashing
    It will be crashing because you pass it invalid data. If you want to work on a corrupt image, it's best to do all the decoding yourself and then fill QImage with proper data manually.

    First create an emtpy QImage object with a defined size and format (QImage::Format_Indexed8 will probably be best for a gif image).
    Then fill the color table based on the data from the corrupt file.
    Then fill pixel data either using QImage::setPixel or with QImage::bits() if you have the data in a proper format. The data needs to be formatted linearly and it should contain indexes of the color table. You can't just copy the data straight into the pixel buffer of QImage because GIF stores it compressed, so you need to decompress it first manually.
    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.


  2. #2
    Join Date
    May 2007
    Posts
    110
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    2

    Default Re: loadFromData() of QImage crash in case of .gif loading

    Quote Originally Posted by wysota View Post
    It will be crashing because you pass it invalid data. If you want to work on a corrupt image, it's best to do all the decoding yourself and then fill QImage with proper data manually.

    First create an emtpy QImage object with a defined size and format (QImage::Format_Indexed8 will probably be best for a gif image).
    Then fill the color table based on the data from the corrupt file.
    Then fill pixel data either using QImage::setPixel or with QImage::bits() if you have the data in a proper format. The data needs to be formatted linearly and it should contain indexes of the color table. You can't just copy the data straight into the pixel buffer of QImage because GIF stores it compressed, so you need to decompress it first manually.
    I m so confused, can u send some sample code for this... Can u tell me some easiest soltuin for this..
    Our software will scan a lakh/multi thousand files and show the preveiw of all files one by one. So GIF or other files's preview process should be fast.

    Is there any alternative or kind send some sample code for this
    Thanks
    Santosh

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

    Default Re: loadFromData() of QImage crash in case of .gif loading

    Quote Originally Posted by santosh.kumar View Post
    I m so confused, can u send some sample code for this...
    No, I can't. I don't intend to do your work for you.
    Can u tell me some easiest soltuin for this..
    Sure. Pay someone to write the application for you.
    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. loadFromData() of QImage -crash in case of .gif loading
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2011, 11:56
  2. Loading a raw image into QImage
    By Luc4 in forum Qt Programming
    Replies: 6
    Last Post: 16th May 2010, 15:20
  3. QImage loadFromData
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 22nd March 2008, 18:57
  4. QImage::loadFromData() behaviour
    By Caius Aérobus in forum Qt Programming
    Replies: 10
    Last Post: 29th November 2007, 21:21
  5. QImage loadFromData not run... XPDF data
    By patrik08 in forum Qt Programming
    Replies: 7
    Last Post: 24th April 2007, 11:51

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.