mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-26 05:51:20 +00:00
Support webp file thumbnails
This commit is contained in:
@@ -6,6 +6,7 @@ import AVFoundation
|
||||
import ImageIO
|
||||
import TelegramUIPrivateModule
|
||||
import TelegramCore
|
||||
import WebP
|
||||
|
||||
private enum ResourceFileData {
|
||||
case data(Data)
|
||||
@@ -2119,13 +2120,20 @@ func chatMessageImageFile(account: Account, fileReference: FileMediaReference, t
|
||||
}
|
||||
|
||||
var thumbnailImage: CGImage?
|
||||
if let thumbnailData = thumbnailData, let imageSource = CGImageSourceCreateWithData(thumbnailData as CFData, nil), let image = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) {
|
||||
if fullSizeImage == nil {
|
||||
imageOrientation = imageOrientationFromSource(imageSource)
|
||||
}
|
||||
thumbnailImage = image
|
||||
if thumbnail {
|
||||
fittedSize = CGSize(width: CGFloat(image.width), height: CGFloat(image.height)).aspectFilled(arguments.boundingSize)
|
||||
if let thumbnailData = thumbnailData {
|
||||
if let imageSource = CGImageSourceCreateWithData(thumbnailData as CFData, nil), let image = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) {
|
||||
if fullSizeImage == nil {
|
||||
imageOrientation = imageOrientationFromSource(imageSource)
|
||||
}
|
||||
thumbnailImage = image
|
||||
if thumbnail {
|
||||
fittedSize = CGSize(width: CGFloat(image.width), height: CGFloat(image.height)).aspectFilled(arguments.boundingSize)
|
||||
}
|
||||
} else if let image = WebP.convert(fromWebP: thumbnailData) {
|
||||
thumbnailImage = image.cgImage
|
||||
if thumbnail {
|
||||
fittedSize = CGSize(width: CGFloat(image.size.width), height: CGFloat(image.size.height)).aspectFilled(arguments.boundingSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user