Handling very large images in Qt

2019-02-18 15:42发布

问题:

I can't get Qt to work on images beyond 10,000X10,000. I'm dealing with huge satellite images that are around 2GB each. I considered using memory mapping but the image still occupies space in memory.

QFile file("c://qt//a.ras");
file.open(QIODevice::ReadOnly);
qint64 size = file.size();
uchar *img=file.map(0,size);
QImage I(img,w,h,QImage::Format_ARGB32);

Can anyone tell me a more efficient way to deal with large images in Qt?

回答1:

Qgraphicsview and a set of image tiles, the view handles all the scrolling and world coords for you.
Then you just have to either pre-chop the images into tiles in advance or pull a section of image data on the fly



回答2:

Can you use some sort of tiling strategy to load and manipulate the image piecewise, instead of all at once?



回答3:

I'm guessing you're using a 32-bit OS and you're running out of address space. The easiest solution may be to use a 64-bit OS (e.g. Windows 7 x64) and compile your app for 64-bit. What is your target platform (Windows, Mac OS X, Linux etc.)?

This may help.