mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 15:47:11 +02:00
Show only box(512,512) .webp as stickers.
This commit is contained in:
parent
9cf15da2b1
commit
8aafe6ba0e
5 changed files with 18 additions and 18 deletions
|
@ -37,8 +37,6 @@ enum {
|
|||
AudioVoiceMsgMaxLength = 100 * 60, // 100 minutes
|
||||
AudioVoiceMsgChannels = 2, // stereo
|
||||
|
||||
StickerMaxSize = 2048, // 2048x2048 is a max image size for sticker
|
||||
|
||||
PreloadHeightsCount = 3, // when 3 screens to scroll left make a preload request
|
||||
|
||||
SearchPeopleLimit = 5,
|
||||
|
|
|
@ -47,7 +47,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace {
|
||||
|
||||
const auto kAnimatedStickerDimensions = QSize(512, 512);
|
||||
const auto kAnimatedStickerDimensions = QSize(
|
||||
kStickerSideSize,
|
||||
kStickerSideSize);
|
||||
|
||||
QString JoinStringList(const QStringList &list, const QString &separator) {
|
||||
const auto count = list.size();
|
||||
|
@ -570,15 +572,11 @@ void DocumentData::setattributes(
|
|||
}, [&](const MTPDdocumentAttributeHasStickers &data) {
|
||||
});
|
||||
}
|
||||
if (type == StickerDocument) {
|
||||
if (dimensions.width() <= 0
|
||||
|| dimensions.height() <= 0
|
||||
|| dimensions.width() > StickerMaxSize
|
||||
|| dimensions.height() > StickerMaxSize
|
||||
|| !saveToCache()) {
|
||||
type = FileDocument;
|
||||
_additional = nullptr;
|
||||
}
|
||||
if (type == StickerDocument
|
||||
&& (!GoodStickerDimensions(dimensions.width(), dimensions.height())
|
||||
|| (size > Storage::kMaxStickerBytesSize))) {
|
||||
type = FileDocument;
|
||||
_additional = nullptr;
|
||||
}
|
||||
if (isAudioFile() || isAnimation() || isVoiceMessage()) {
|
||||
setMaybeSupportsStreaming(true);
|
||||
|
|
|
@ -320,6 +320,14 @@ enum DocumentType {
|
|||
WallPaperDocument = 7,
|
||||
};
|
||||
|
||||
inline constexpr auto kStickerSideSize = 512;
|
||||
|
||||
[[nodiscard]] inline bool GoodStickerDimensions(int width, int height) {
|
||||
return (width > 0 && width <= kStickerSideSize)
|
||||
&& (height > 0 && height <= kStickerSideSize)
|
||||
&& (width == kStickerSideSize || height == kStickerSideSize);
|
||||
}
|
||||
|
||||
using MediaKey = QPair<uint64, uint64>;
|
||||
|
||||
class AudioMsgId {
|
||||
|
|
|
@ -136,10 +136,9 @@ QSize Sticker::GetAnimatedEmojiSize(not_null<Main::Session*> session) {
|
|||
QSize Sticker::GetAnimatedEmojiSize(
|
||||
not_null<Main::Session*> session,
|
||||
QSize documentSize) {
|
||||
constexpr auto kIdealStickerSize = 512;
|
||||
const auto zoom = GetEmojiStickerZoom(session);
|
||||
const auto convert = [&](int size) {
|
||||
return int(size * st::maxStickerSize * zoom / kIdealStickerSize);
|
||||
return int(size * st::maxStickerSize * zoom / kStickerSideSize);
|
||||
};
|
||||
return { convert(documentSize.width()), convert(documentSize.height()) };
|
||||
}
|
||||
|
|
|
@ -842,10 +842,7 @@ void FileLoadTask::process() {
|
|||
|
||||
if (ValidateThumbDimensions(w, h)) {
|
||||
isSticker = Core::IsMimeSticker(filemime)
|
||||
&& (w > 0)
|
||||
&& (h > 0)
|
||||
&& (w <= StickerMaxSize)
|
||||
&& (h <= StickerMaxSize)
|
||||
&& GoodStickerDimensions(w, h)
|
||||
&& (filesize < Storage::kMaxStickerBytesSize);
|
||||
if (isSticker) {
|
||||
attributes.push_back(MTP_documentAttributeSticker(
|
||||
|
|
Loading…
Add table
Reference in a new issue