2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Support blurred backgrounds.

This commit is contained in:
John Preston
2019-02-06 17:38:37 +03:00
parent e7043c4d63
commit fe21b5a502
6 changed files with 277 additions and 9 deletions

View File

@@ -150,6 +150,10 @@ bool WallPaper::isLocal() const {
return !document() && thumbnail();
}
bool WallPaper::isBlurred() const {
return _settings & MTPDwallPaperSettings::Flag::f_blur;
}
int WallPaper::patternIntensity() const {
return _intensity;
}
@@ -482,6 +486,19 @@ QImage PreparePatternImage(
return image;
}
QImage PrepareBlurredBackground(QImage image) {
constexpr auto kSize = 900;
constexpr auto kRadius = 24;
if (image.width() > kSize || image.height() > kSize) {
image = image.scaled(
kSize,
kSize,
Qt::KeepAspectRatio,
Qt::SmoothTransformation);
}
return Images::BlurLargeImage(image, kRadius);
}
namespace details {
WallPaper UninitializedWallPaper() {
@@ -973,6 +990,9 @@ void ChatBackground::setPreparedImage(QImage original, QImage prepared) {
Expects(prepared.width() > 0 && prepared.height() > 0);
_original = std::move(original);
if (!_paper.isPattern() && _paper.isBlurred()) {
prepared = Data::PrepareBlurredBackground(std::move(prepared));
}
if (adjustPaletteRequired()) {
adjustPaletteUsingBackground(prepared);
}

View File

@@ -28,6 +28,7 @@ public:
[[nodiscard]] bool isCreator() const;
[[nodiscard]] bool isDark() const;
[[nodiscard]] bool isLocal() const;
[[nodiscard]] bool isBlurred() const;
[[nodiscard]] int patternIntensity() const;
[[nodiscard]] bool hasShareUrl() const;
[[nodiscard]] QString shareUrl() const;
@@ -89,6 +90,7 @@ QImage PreparePatternImage(
QColor bg,
QColor fg,
int intensity);
QImage PrepareBlurredBackground(QImage image);
namespace details {