mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Use always the same sizes for group layout.
For the floating point precision to matter less in the album layout decisions use always full image sizes for layout when sending an album and when displaying it. Fixes #5049.
This commit is contained in:
@@ -41,6 +41,16 @@ bool ValidVideoForAlbum(const FileMediaInformation::Video &video) {
|
||||
return ValidateThumbDimensions(width, height);
|
||||
}
|
||||
|
||||
QSize PrepareShownDimensions(const QImage &preview) {
|
||||
constexpr auto kMaxWidth = 1280;
|
||||
constexpr auto kMaxHeight = 1280;
|
||||
|
||||
const auto result = preview.size();
|
||||
return (result.width() > kMaxWidth || result.height() > kMaxHeight)
|
||||
? result.scaled(kMaxWidth, kMaxHeight, Qt::KeepAspectRatio)
|
||||
: result;
|
||||
}
|
||||
|
||||
bool PrepareAlbumMediaIsWaiting(
|
||||
QSemaphore &semaphore,
|
||||
PreparedFile &file,
|
||||
@@ -69,6 +79,7 @@ bool PrepareAlbumMediaIsWaiting(
|
||||
if (const auto image = base::get_if<Image>(
|
||||
&file.information->media)) {
|
||||
if (ValidPhotoForAlbum(*image)) {
|
||||
file.shownDimensions = PrepareShownDimensions(image->data);
|
||||
file.preview = Images::prepareOpaque(image->data.scaledToWidth(
|
||||
std::min(previewWidth, convertScale(image->data.width()))
|
||||
* cIntRetinaFactor(),
|
||||
@@ -80,6 +91,7 @@ bool PrepareAlbumMediaIsWaiting(
|
||||
&file.information->media)) {
|
||||
if (ValidVideoForAlbum(*video)) {
|
||||
auto blurred = Images::prepareBlur(Images::prepareOpaque(video->thumbnail));
|
||||
file.shownDimensions = PrepareShownDimensions(video->thumbnail);
|
||||
file.preview = std::move(blurred).scaledToWidth(
|
||||
previewWidth * cIntRetinaFactor(),
|
||||
Qt::SmoothTransformation);
|
||||
|
Reference in New Issue
Block a user