mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Faster blurhash decode
This commit is contained in:
parent
96c4d05730
commit
392c07adbe
1 changed files with 9 additions and 2 deletions
|
@ -22,9 +22,14 @@ BlurhashRunnable::run()
|
||||||
return;
|
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(),
|
auto decoded = blurhash::decode(QUrl::fromPercentEncoding(m_id.toUtf8()).toStdString(),
|
||||||
m_requestedSize.width(),
|
blurhashDecodeSize.width(),
|
||||||
m_requestedSize.height());
|
blurhashDecodeSize.height());
|
||||||
if (decoded.image.empty()) {
|
if (decoded.image.empty()) {
|
||||||
emit error(QStringLiteral("Failed decode!"));
|
emit error(QStringLiteral("Failed decode!"));
|
||||||
return;
|
return;
|
||||||
|
@ -36,5 +41,7 @@ BlurhashRunnable::run()
|
||||||
(int)decoded.width * 3,
|
(int)decoded.width * 3,
|
||||||
QImage::Format_RGB888);
|
QImage::Format_RGB888);
|
||||||
|
|
||||||
|
image = image.scaled(m_requestedSize);
|
||||||
|
|
||||||
emit done(image.convertToFormat(QImage::Format_RGB32));
|
emit done(image.convertToFormat(QImage::Format_RGB32));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue