| 44 | // ---- QImage API (avoids QPixmap round-trip in ContinuousPageWidget) --------- |
| 45 | |
| 46 | QImage scaleImage(const QImage &image, int width, int height, ScaleMethod method) |
| 47 | { |
| 48 | if ((image.width() == width && image.height() == height) || image.isNull()) |
| 49 | return image; |
| 50 | |
| 51 | switch (method) { |
| 52 | case ScaleMethod::Nearest: |
| 53 | return image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::FastTransformation); |
| 54 | case ScaleMethod::Bilinear: |
| 55 | return image.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); |
| 56 | case ScaleMethod::Lanczos: |
| 57 | return scaleImageLancir(image, width, height); |
| 58 | } |
| 59 | return image; |
| 60 | } |