Results 1 to 7 of 7

Thread: ReaderImage can Read a huge image (10000*40000 format jpeg), how it wrok ?

  1. #1
    Join Date
    Dec 2015
    Posts
    4
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Post ReaderImage can Read a huge image (10000*40000 format jpeg), how it wrok ?

    Hi , man ,i'm new boy in here , i test some picture with qimage ,yeah , it's work well, but for huge qimage (>200M ), it's just like dog shit.
    so i change my way to using ReaderImage to Read a huge image(format like jpeg ) with setScaledSize(), omg , it's work like a angle , but i want to know ReaderImage how to do that ? , for another word , what the theory it is ? it's like riddle around me again and again ! man , do you konw ?

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ReaderImage can Read a huge image (10000*40000 format jpeg), how it wrok ?

    By ReaderImage, you mean QImageReader, right?

    QImage loads the whole image, which explains the limitations you have run into.
    By contrast, QImageReader probably keeps only a small region of the image in memory at a given time. This is only possible for algorithms which are inherently local, such as scaling. In order to compute the value of a pixel of the scaled image, you only need to inspect the region of the original image in the same relative position. When you are done, you can move to another region of the original image and reuse the same buffer in memory.

  3. #3
    Join Date
    Dec 2015
    Posts
    4
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: ReaderImage can Read a huge image (10000*40000 format jpeg), how it wrok ?

    Yeah , i went to proof for minutes ago , the data like this , it's cost litter memory , so i'm curious about how it got this way ! do you have good article introduce for me !
    M[%6[6V(@Q4{{RC`)54AN_Q.png

    thsk for much.
    by gxjun

  4. #4
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ReaderImage can Read a huge image (10000*40000 format jpeg), how it wrok ?

    I am sorry, but I have no idea what you mean.

  5. #5
    Join Date
    Dec 2015
    Posts
    4
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: ReaderImage can Read a huge image (10000*40000 format jpeg), how it wrok ?

    i'mean that , do you know QImageRead Based on what algorithm to deal huge image( &jpeg),?

  6. #6
    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: ReaderImage can Read a huge image (10000*40000 format jpeg), how it wrok ?

    QImage reads the entire image into RAM and keeps an editable data structure. This structure is typically much larger than the file size.

    QImageReader reads the image data a piece at a time, processes the current piece, and then discards it. In your case, the reader reads a portion of the source image big enough to determine the pixels of the first portion of the scaled result, computes that scaled image portion, and then discards the input. In this way it never needs to hold the entire source in memory and can build a much smaller result.

  7. The following user says thank you to ChrisW67 for this useful post:

    huifeidmeng (7th January 2016)

  8. #7
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: ReaderImage can Read a huge image (10000*40000 format jpeg), how it wrok ?

    Again, it's QImageReader. Please use the correct name so that other users can search the forum more efficiently.

    Have a look into QImageReader's source code. You'll see that the algorithms depend on the format of the image; the internal class QJpegHandler implements those algorithms for JPEG images. QJpegHandler in turn delegates the work to libjpeg. libjpeg's maintainers may be able to answer your question.

    What is so mysterious about this scaling algorithm? I explained how its local nature allowed implementations that kept a small region of the image in memory. I haven't checked libjpeg, but I suppose it must work this way (except that image data must be decompressed on the fly, too).

  9. The following user says thank you to yeye_olive for this useful post:

    huifeidmeng (7th January 2016)

Similar Threads

  1. Read huge files effectively
    By MrAnderson1983 in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2014, 08:18
  2. read a huge file over 100GB
    By jesse_mark in forum Qt Programming
    Replies: 3
    Last Post: 23rd April 2013, 23:11
  3. Replies: 4
    Last Post: 22nd May 2011, 17:26
  4. Save pictures in JPEG format into QDataStream
    By Eos Pengwern in forum Qt Programming
    Replies: 2
    Last Post: 31st December 2009, 13:14
  5. Saving image in jpeg format failed
    By febil in forum Qt Programming
    Replies: 5
    Last Post: 23rd April 2009, 11:33

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.