PDA

View Full Version : how to scale image?



tiaoweiliao
9th March 2018, 03:06
I am currently doing imageViewer.

I have a problem , when i scale a image , i find QImage::scale so slow.

this leads UI thread block.

my image file size is 3MB and size is 8900*8105.

Do you have any good Suggestions?

thanks.


QTime time;
time.start();
QImage image(imagePath);
qDebug()<<"load image time elapsed is : "<<time.elapsed();//load image time elapsed is : 4407
image.scaled(image.width() * 0.09 , image.height() * 0.09 , Qt::KeepAspectRatio , Qt::SmoothTransformation);
qDebug()<<"scaled image time elapsed is : "<<time.elapsed();//scaled image time elapsed is : 5231

ChristianEhrlicher
9th March 2018, 08:04
Yu can use QtConcurrent to move the calculation to a different thread. See https://doc.qt.io/qt-5.10/qtconcurrentrun.html - there is an example on how to modify a QImage