mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Fix image blur
This commit is contained in:
parent
cc12a925bb
commit
0f3cf634a2
@ -639,7 +639,10 @@ public func chatMessagePhotoInternal(photoData: Signal<(Data?, Data?, Bool), NoE
|
|||||||
var blurredThumbnailImage: UIImage?
|
var blurredThumbnailImage: UIImage?
|
||||||
if let thumbnailImage = thumbnailImage {
|
if let thumbnailImage = thumbnailImage {
|
||||||
let thumbnailSize = CGSize(width: thumbnailImage.width, height: thumbnailImage.height)
|
let thumbnailSize = CGSize(width: thumbnailImage.width, height: thumbnailImage.height)
|
||||||
let thumbnailContextSize = thumbnailSize.aspectFitted(CGSize(width: 150.0, height: 150.0))
|
|
||||||
|
let initialThumbnailContextFittingSize = fittedSize.fitted(CGSize(width: 100.0, height: 100.0))
|
||||||
|
|
||||||
|
let thumbnailContextSize = thumbnailSize.aspectFitted(initialThumbnailContextFittingSize)
|
||||||
let thumbnailContext = DrawingContext(size: thumbnailContextSize, scale: 1.0)
|
let thumbnailContext = DrawingContext(size: thumbnailContextSize, scale: 1.0)
|
||||||
thumbnailContext.withFlippedContext { c in
|
thumbnailContext.withFlippedContext { c in
|
||||||
c.interpolationQuality = .none
|
c.interpolationQuality = .none
|
||||||
@ -647,7 +650,25 @@ public func chatMessagePhotoInternal(photoData: Signal<(Data?, Data?, Bool), NoE
|
|||||||
}
|
}
|
||||||
telegramFastBlur(Int32(thumbnailContextSize.width), Int32(thumbnailContextSize.height), Int32(thumbnailContext.bytesPerRow), thumbnailContext.bytes)
|
telegramFastBlur(Int32(thumbnailContextSize.width), Int32(thumbnailContextSize.height), Int32(thumbnailContext.bytesPerRow), thumbnailContext.bytes)
|
||||||
|
|
||||||
blurredThumbnailImage = thumbnailContext.generateImage()
|
var thumbnailContextFittingSize = CGSize(width: floor(arguments.drawingSize.width * 0.5), height: floor(arguments.drawingSize.width * 0.5))
|
||||||
|
if thumbnailContextFittingSize.width < 150.0 || thumbnailContextFittingSize.height < 150.0 {
|
||||||
|
thumbnailContextFittingSize = thumbnailContextFittingSize.aspectFilled(CGSize(width: 150.0, height: 150.0))
|
||||||
|
}
|
||||||
|
|
||||||
|
if thumbnailContextFittingSize.width > thumbnailContextSize.width {
|
||||||
|
let additionalContextSize = thumbnailContextFittingSize
|
||||||
|
let additionalBlurContext = DrawingContext(size: additionalContextSize, scale: 1.0)
|
||||||
|
additionalBlurContext.withFlippedContext { c in
|
||||||
|
c.interpolationQuality = .default
|
||||||
|
if let image = thumbnailContext.generateImage()?.cgImage {
|
||||||
|
c.draw(image, in: CGRect(origin: CGPoint(), size: additionalContextSize))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
telegramFastBlur(Int32(additionalContextSize.width), Int32(additionalContextSize.height), Int32(additionalBlurContext.bytesPerRow), additionalBlurContext.bytes)
|
||||||
|
blurredThumbnailImage = additionalBlurContext.generateImage()
|
||||||
|
} else {
|
||||||
|
blurredThumbnailImage = thumbnailContext.generateImage()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.withFlippedContext { c in
|
context.withFlippedContext { c in
|
||||||
|
@ -516,11 +516,13 @@ func storageUsageController(account: Account) -> ViewController {
|
|||||||
}
|
}
|
||||||
sizeIndex[categoryId] = (true, categorySize)
|
sizeIndex[categoryId] = (true, categorySize)
|
||||||
totalSize += categorySize
|
totalSize += categorySize
|
||||||
let index = itemIndex
|
if categorySize > 1024 {
|
||||||
items.append(ActionSheetCheckboxItem(title: stringForCategory(strings: presentationData.strings, category: categoryId), label: dataSizeString(categorySize), value: true, action: { value in
|
let index = itemIndex
|
||||||
toggleCheck(categoryId, index)
|
items.append(ActionSheetCheckboxItem(title: stringForCategory(strings: presentationData.strings, category: categoryId), label: dataSizeString(categorySize), value: true, action: { value in
|
||||||
}))
|
toggleCheck(categoryId, index)
|
||||||
itemIndex += 1
|
}))
|
||||||
|
itemIndex += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user