mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Force non-transparency for WebDocuments in PhotoData.
This commit is contained in:
parent
b0f54822e0
commit
09e014cc14
2 changed files with 22 additions and 4 deletions
|
@ -29,6 +29,15 @@ using Data::PhotoSize;
|
||||||
using Data::PhotoSizeIndex;
|
using Data::PhotoSizeIndex;
|
||||||
using Data::kPhotoSizeCount;
|
using Data::kPhotoSizeCount;
|
||||||
|
|
||||||
|
[[nodiscard]] QImage ValidatePhotoImage(
|
||||||
|
QImage image,
|
||||||
|
const Data::CloudFile &file) {
|
||||||
|
return (v::is<WebFileLocation>(file.location.file().data)
|
||||||
|
&& image.format() == QImage::Format_ARGB32)
|
||||||
|
? Images::prepareOpaque(std::move(image))
|
||||||
|
: image;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
PhotoData::PhotoData(not_null<Data::Session*> owner, PhotoId id)
|
PhotoData::PhotoData(not_null<Data::Session*> owner, PhotoId id)
|
||||||
|
@ -296,7 +305,10 @@ void PhotoData::load(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (const auto active = activeMediaView()) {
|
if (const auto active = activeMediaView()) {
|
||||||
active->set(validSize, goodFor, std::move(result));
|
active->set(
|
||||||
|
validSize,
|
||||||
|
goodFor,
|
||||||
|
ValidatePhotoImage(std::move(result), _images[valid]));
|
||||||
}
|
}
|
||||||
if (validSize == PhotoSize::Large && goodFor == validSize) {
|
if (validSize == PhotoSize::Large && goodFor == validSize) {
|
||||||
_owner->photoLoadDone(this);
|
_owner->photoLoadDone(this);
|
||||||
|
@ -355,15 +367,21 @@ void PhotoData::updateImages(
|
||||||
_inlineThumbnailBytes = inlineThumbnailBytes;
|
_inlineThumbnailBytes = inlineThumbnailBytes;
|
||||||
}
|
}
|
||||||
const auto update = [&](PhotoSize size, const ImageWithLocation &data) {
|
const auto update = [&](PhotoSize size, const ImageWithLocation &data) {
|
||||||
|
const auto index = PhotoSizeIndex(size);
|
||||||
Data::UpdateCloudFile(
|
Data::UpdateCloudFile(
|
||||||
_images[PhotoSizeIndex(size)],
|
_images[index],
|
||||||
data,
|
data,
|
||||||
owner().cache(),
|
owner().cache(),
|
||||||
Data::kImageCacheTag,
|
Data::kImageCacheTag,
|
||||||
[=](Data::FileOrigin origin) { load(size, origin); },
|
[=](Data::FileOrigin origin) { load(size, origin); },
|
||||||
[=](QImage preloaded) {
|
[=](QImage preloaded) {
|
||||||
if (const auto media = activeMediaView()) {
|
if (const auto media = activeMediaView()) {
|
||||||
media->set(size, size, data.preloaded);
|
media->set(
|
||||||
|
size,
|
||||||
|
size,
|
||||||
|
ValidatePhotoImage(
|
||||||
|
std::move(preloaded),
|
||||||
|
_images[index]));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -129,7 +129,7 @@ std::unique_ptr<Result> Result::Create(
|
||||||
if (!result->_photo && !result->_document && imageThumb) {
|
if (!result->_photo && !result->_document && imageThumb) {
|
||||||
result->_thumbnail.update(result->_session, ImageWithLocation{
|
result->_thumbnail.update(result->_session, ImageWithLocation{
|
||||||
.location = Images::FromWebDocument(*data.vthumb())
|
.location = Images::FromWebDocument(*data.vthumb())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return &data.vsend_message();
|
return &data.vsend_message();
|
||||||
}, [&](const MTPDbotInlineMediaResult &data) {
|
}, [&](const MTPDbotInlineMediaResult &data) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue