diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2024-01-07 21:52:20 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2024-01-07 21:52:20 +0100 |
commit | 392c07adbe42f4b424495034942e3c48b6b69856 (patch) | |
tree | b20673a651ac2dfdb3e67af8b476527b0b984182 /src | |
parent | Merge pull request #1649 from duarm/swipe-toggle (diff) | |
download | nheko-392c07adbe42f4b424495034942e3c48b6b69856.tar.xz |
Faster blurhash decode
Diffstat (limited to 'src')
-rw-r--r-- | src/BlurhashProvider.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/BlurhashProvider.cpp b/src/BlurhashProvider.cpp index d4482419..1fdc9319 100644 --- a/src/BlurhashProvider.cpp +++ b/src/BlurhashProvider.cpp @@ -22,9 +22,14 @@ BlurhashRunnable::run() return; } + auto blurhashDecodeSize = m_requestedSize; + if (blurhashDecodeSize.height() > 100 && blurhashDecodeSize.width() > 100) { + blurhashDecodeSize.scale(100, 100, Qt::AspectRatioMode::KeepAspectRatio); + } + auto decoded = blurhash::decode(QUrl::fromPercentEncoding(m_id.toUtf8()).toStdString(), - m_requestedSize.width(), - m_requestedSize.height()); + blurhashDecodeSize.width(), + blurhashDecodeSize.height()); if (decoded.image.empty()) { emit error(QStringLiteral("Failed decode!")); return; @@ -36,5 +41,7 @@ BlurhashRunnable::run() (int)decoded.width * 3, QImage::Format_RGB888); + image = image.scaled(m_requestedSize); + emit done(image.convertToFormat(QImage::Format_RGB32)); } |