Thank you for help. Actually I can use QImageReader to split it as:
avoiding memory wasting. Any other suggestions, guys?Qt Code:
To copy to clipboard, switch view to plain text mode![]()
Thank you for help. Actually I can use QImageReader to split it as:
avoiding memory wasting. Any other suggestions, guys?Qt Code:
To copy to clipboard, switch view to plain text mode![]()
Last edited by Astrologer; 28th April 2010 at 13:42.
From the QImageReader docs:
Depending on the underlying support in the image format, this can save memory and speed up loading of images.
So even if you can get a scaled image from QImageReader, it does not necessarily mean that you can save memory.
I see your point. That's exactly the problem that I am longing for solution which will help me. I have an image let's say 20000x20000. If not up to QImageReader I can't see a way QT can handle it. If I feed the image directly to QImage it returns zero width and zero height purpotedly because of the size. If I do it with example written above, it works and saves a thumbnail size of 500x500. Memory can be saved as I pointed out by cropping the big one into slices size of one pixel, for example.
Last edited by Astrologer; 28th April 2010 at 13:42.
Hey, guys. Ain't there any idea?![]()
Qt doesn't really give you access to the primitive graphics and image file functions you need to do this properly. If your solution works for your purposes, then you're done. But as noted, there are potential problems with it.
Most modern image formats use some sort of compression. In JPEG, images are processed in 8x8 blocks, so you would need access to the raw JPEG library to read strips, which would decompress into more than a single line. Other formats, like JPEG2000, use wavelet transforms for compression, and the spatial information in the image is scattered throughout the compressed data, making retrieval of individual lines or blocks problematic.
For similar reasons, your procedure of removing blocks, reducing them and then stitching them back together to produce a single, reduced image may produce "seams" around the edges of your individual tiles, because the compression algorithm relies on a broad "neighborhood" around each pixel and behaves differently near edges. You'll want to inspect your images carefully after reassembly to see if these are visible, or if they are objectionable.
A better solution would be to use a tool like ImageMagick, an image processing toolkit that can be used from either the command line or through a C++ interface. It allows you to set the maximum amount of memory an operation will consume, and is careful not to exceed that limit, although more memory results in greater execution speed. But when dealing with really huge images, it is often the best solution available. It's scaling algorithms are top-notch, as well, and their advantages and shortcomings are carefully documented. Plus, it's free.
Astrologer (29th April 2010)
Yes, it seems to be a great library, though I just skimmed over it. I am going to plough on with the library. Thank you all, guys.
Bookmarks