diff --git a/image_processing/resize_image.cpp b/image_processing/resize_image.cpp index a7ca7b61..167117e2 100644 --- a/image_processing/resize_image.cpp +++ b/image_processing/resize_image.cpp @@ -1,5 +1,6 @@ #include "resize_image.h" +#include "qmath.h" #include #include #include @@ -293,14 +294,17 @@ QImage scaleImageLanczos(const QImage &sourceImage, int targetWidth, int targetH rows[i] = i; } - QFuture> future = QtConcurrent::mapped(rows, [targetWidth, targetHeight, &sourceImage, a](int y) { - return processRow(y, targetWidth, targetHeight, sourceImage, a); + // Use a QVector to store the results of the processed rows + QVector> results(targetHeight); + + // Launch concurrent tasks using QtConcurrent::map, which modifies the container in place + QtConcurrent::blockingMap(rows, [&results, targetWidth, targetHeight, &sourceImage, a](int y) { + results[y] = processRow(y, targetWidth, targetHeight, sourceImage, a); }); - future.waitForFinished(); - + // Set the pixels in the target image for (int y = 0; y < targetHeight; ++y) { - QVector row = future.resultAt(y); + const QVector &row = results[y]; for (int x = 0; x < targetWidth; ++x) { targetImage.setPixel(x, y, row[x]); } @@ -308,7 +312,6 @@ QImage scaleImageLanczos(const QImage &sourceImage, int targetWidth, int targetH return targetImage; } - QPixmap scalePixmapLanczosQt(const QPixmap &pixmap, int targetWidth, int targetHeight, int a) { QImage sourceImage = pixmap.toImage();