mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Fix Qt5 compatibility
This commit is contained in:
parent
819f456d6e
commit
8f42aae53a
@ -1,5 +1,6 @@
|
|||||||
#include "resize_image.h"
|
#include "resize_image.h"
|
||||||
|
|
||||||
|
#include "qmath.h"
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
@ -293,14 +294,17 @@ QImage scaleImageLanczos(const QImage &sourceImage, int targetWidth, int targetH
|
|||||||
rows[i] = i;
|
rows[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFuture<QVector<QRgb>> future = QtConcurrent::mapped(rows, [targetWidth, targetHeight, &sourceImage, a](int y) {
|
// Use a QVector to store the results of the processed rows
|
||||||
return processRow(y, targetWidth, targetHeight, sourceImage, a);
|
QVector<QVector<QRgb>> 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) {
|
for (int y = 0; y < targetHeight; ++y) {
|
||||||
QVector<QRgb> row = future.resultAt(y);
|
const QVector<QRgb> &row = results[y];
|
||||||
for (int x = 0; x < targetWidth; ++x) {
|
for (int x = 0; x < targetWidth; ++x) {
|
||||||
targetImage.setPixel(x, y, row[x]);
|
targetImage.setPixel(x, y, row[x]);
|
||||||
}
|
}
|
||||||
@ -308,7 +312,6 @@ QImage scaleImageLanczos(const QImage &sourceImage, int targetWidth, int targetH
|
|||||||
|
|
||||||
return targetImage;
|
return targetImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap scalePixmapLanczosQt(const QPixmap &pixmap, int targetWidth, int targetHeight, int a)
|
QPixmap scalePixmapLanczosQt(const QPixmap &pixmap, int targetWidth, int targetHeight, int a)
|
||||||
{
|
{
|
||||||
QImage sourceImage = pixmap.toImage();
|
QImage sourceImage = pixmap.toImage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user