mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Animated emoji thumbnail fix
This commit is contained in:
parent
4c32f661e0
commit
1538f60ceb
@ -189,8 +189,6 @@ func experimentalConvertCompressedLottieToCombinedMp4(data: Data, size: CGSize,
|
||||
return
|
||||
}
|
||||
|
||||
let scale = size.width / 512.0
|
||||
|
||||
let bytesPerRow = (4 * Int(size.width) + 15) & (~15)
|
||||
|
||||
var currentFrame: Int32 = 0
|
||||
|
@ -136,15 +136,14 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
}
|
||||
}
|
||||
|
||||
if self.telegramFile == nil {
|
||||
self.emojiFile = item.associatedData.animatedEmojiStickers[item.message.text.trimmedEmoji]?.file
|
||||
|
||||
if let emojiFile = self.emojiFile {
|
||||
self.imageNode.setSignal(chatMessageAnimatedSticker(postbox: item.context.account.postbox, file: emojiFile, small: false, size: CGSize(width: 384.0, height: 384.0), thumbnail: false))
|
||||
if self.telegramFile == nil, let emojiFile = item.associatedData.animatedEmojiStickers[item.message.text.trimmedEmoji]?.file {
|
||||
if self.emojiFile?.id != emojiFile.id {
|
||||
self.emojiFile = emojiFile
|
||||
let dimensions = emojiFile.dimensions ?? CGSize(width: 512.0, height: 512.0)
|
||||
self.imageNode.setSignal(chatMessageAnimatedSticker(postbox: item.context.account.postbox, file: emojiFile, small: false, size: dimensions.aspectFilled(CGSize(width: 384.0, height: 384.0)), thumbnail: false))
|
||||
self.disposable.set(freeMediaFileInteractiveFetched(account: item.context.account, fileReference: .message(message: MessageReference(item.message), media: emojiFile)).start())
|
||||
self.updateVisibility()
|
||||
}
|
||||
|
||||
self.updateVisibility()
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +178,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
|
||||
if let file = file {
|
||||
let dimensions = file.dimensions ?? CGSize(width: 512.0, height: 512.0)
|
||||
let fittedSize = isEmoji ? dimensions.aspectFilled(CGSize(width: 384.0, height: 384.0)) : dimensions.aspectFitted(CGSize(width: 384.0, height: 384.0))
|
||||
let fittedSize = isEmoji ? dimensions.aspectFilled(CGSize(width: 480.0, height: 480.0)) : dimensions.aspectFitted(CGSize(width: 384.0, height: 384.0))
|
||||
self.animationNode.setup(account: item.context.account, resource: file.resource, width: Int(fittedSize.width), height: Int(fittedSize.height), playbackMode: playbackMode, mode: .cached)
|
||||
}
|
||||
}
|
||||
|
@ -535,8 +535,10 @@ public func chatMessageAnimatedSticker(postbox: Postbox, file: TelegramMediaFile
|
||||
|
||||
if let blurredThumbnailImage = blurredThumbnailImage {
|
||||
c.interpolationQuality = .low
|
||||
let thumbnailFittedSize = blurredThumbnailImage.size.aspectFilled(fittedRect.size)
|
||||
let thumbnailFittedRect = CGRect(origin: CGPoint(x: fittedRect.origin.x - (thumbnailFittedSize.width - fittedRect.width) / 2.0, y: fittedRect.origin.y - (thumbnailFittedSize.height - fittedRect.height) / 2.0), size: thumbnailFittedSize)
|
||||
let thumbnailScaledInset = thumbnailInset * (fittedRect.width / blurredThumbnailImage.size.width)
|
||||
c.draw(blurredThumbnailImage.cgImage!, in: fittedRect.insetBy(dx: -thumbnailScaledInset, dy: -thumbnailScaledInset))
|
||||
c.draw(blurredThumbnailImage.cgImage!, in: thumbnailFittedRect.insetBy(dx: -thumbnailScaledInset, dy: -thumbnailScaledInset))
|
||||
}
|
||||
|
||||
if let fullSizeImage = fullSizeImage, let cgImage = fullSizeImage.0.cgImage, let cgImageAlpha = fullSizeImage.1.cgImage {
|
||||
@ -549,6 +551,9 @@ public func chatMessageAnimatedSticker(postbox: Postbox, file: TelegramMediaFile
|
||||
}
|
||||
}
|
||||
|
||||
let img = context.generateImage()
|
||||
let cgImg = img?.cgImage
|
||||
|
||||
return context
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user