Question

I am working in a QT project (5.1.1). The main window shows a large image as a QLabel object which includes a QPixmap (which contains a QImage). My question is simple.... Are there some way to compress the image?

UPDATE:

How large is the image? width: 1624 pixels. height: 482*300 pixels = 144600 pixels (more or less) The idea is to manage this image with 100 Mbs of memory or less

And what do you want to accomplish, is it about using less memory? Yes, I'd like to use the minimum necessary memory without lose a lot of quality.....

Where does the image come from, is it a drawing or a photograph? It is extracted from a webcam and we manage each frame.

Do you want lossless or lossy compression? I think this could be the key of my problem. I was searching how configure the types of compression in QImage but I didn't find it. I find parameters to configure the image format, but it doesn't improve the usage memory and it loses quite quality. I am interested to know how configure the compression of the QImage.

Finally, I suppose that my question is: is there some way to compress the QImage with is showed in a QLabel without lose quality?

P.D: I thought to implement some type of cache and load new parts of the image with the scrollbar (the scrollbar is created automatically in the QLabel). P.D2: I didn't added code because I think the question is not complex.... if somebody wants the code, I will added it. P.D3: Is it correct to post this question here or in the http://programmers.stackexchange.com ?

Was it helpful?

Solution

I'm afraid you will have to load the big image at least once to do anything with it.

You can use scaled() func, to get a scaled-down version of your original image, to use in your QLabel.

QImage QImage::scaled(const QSize & size, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode = Qt::FastTransformation) const

Link to docs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top