@@ -261,8 +261,8 @@ public func chatMessageAnimatedStickerBackingData(postbox: Postbox, fileReferenc
261261}
262262
263263
264- public func chatMessageSticker( account: Account , userLocation: MediaResourceUserLocation , file: TelegramMediaFile , small: Bool , fetched: Bool = false , onlyFullSize: Bool = false , thumbnail: Bool = false , synchronousLoad: Bool = false , colorSpace: CGColorSpace ? = nil ) -> Signal < ( TransformImageArguments ) -> DrawingContext ? , NoError > {
265- return chatMessageSticker ( postbox: account. postbox, userLocation: userLocation, file: file, small: small, fetched: fetched, onlyFullSize: onlyFullSize, thumbnail: thumbnail, synchronousLoad: synchronousLoad, colorSpace: colorSpace)
264+ public func chatMessageSticker( account: Account , userLocation: MediaResourceUserLocation , file: TelegramMediaFile , small: Bool , fetched: Bool = false , onlyFullSize: Bool = false , thumbnail: Bool = false , synchronousLoad: Bool = false , colorSpace: CGColorSpace ? = nil , blurThumbnail : Bool = true ) -> Signal < ( TransformImageArguments ) -> DrawingContext ? , NoError > {
265+ return chatMessageSticker ( postbox: account. postbox, userLocation: userLocation, file: file, small: small, fetched: fetched, onlyFullSize: onlyFullSize, thumbnail: thumbnail, synchronousLoad: synchronousLoad, colorSpace: colorSpace, blurThumbnail : blurThumbnail )
266266}
267267
268268public func chatMessageStickerPackThumbnail( postbox: Postbox , resource: MediaResource , animated: Bool = false , synchronousLoad: Bool = false , nilIfEmpty: Bool = false ) -> Signal < ( TransformImageArguments ) -> DrawingContext ? , NoError > {
@@ -318,7 +318,7 @@ public func chatMessageStickerPackThumbnail(postbox: Postbox, resource: MediaRes
318318 }
319319}
320320
321- public func chatMessageSticker( postbox: Postbox , userLocation: MediaResourceUserLocation , file: TelegramMediaFile , small: Bool , fetched: Bool = false , onlyFullSize: Bool = false , thumbnail: Bool = false , synchronousLoad: Bool = false , colorSpace: CGColorSpace ? = nil ) -> Signal < ( TransformImageArguments ) -> DrawingContext ? , NoError > {
321+ public func chatMessageSticker( postbox: Postbox , userLocation: MediaResourceUserLocation , file: TelegramMediaFile , small: Bool , fetched: Bool = false , onlyFullSize: Bool = false , thumbnail: Bool = false , synchronousLoad: Bool = false , colorSpace: CGColorSpace ? = nil , blurThumbnail : Bool = true ) -> Signal < ( TransformImageArguments ) -> DrawingContext ? , NoError > {
322322 let signal : Signal < Tuple3 < Data ? , Data ? , Bool > , NoError >
323323
324324 if thumbnail {
@@ -367,7 +367,7 @@ public func chatMessageSticker(postbox: Postbox, userLocation: MediaResourceUser
367367
368368 var blurredThumbnailImage : UIImage ?
369369 let thumbnailInset : CGFloat = 10.0
370- if let thumbnailImage = thumbnailImage {
370+ if blurThumbnail , let thumbnailImage = thumbnailImage {
371371 let thumbnailSize = thumbnailImage. 0 . size
372372 var thumbnailContextSize = thumbnailSize. aspectFitted ( CGSize ( width: 150.0 , height: 150.0 ) )
373373 let thumbnailDrawingSize = thumbnailContextSize
@@ -403,6 +403,11 @@ public func chatMessageSticker(postbox: Postbox, userLocation: MediaResourceUser
403403 c. interpolationQuality = . low
404404 let thumbnailScaledInset = thumbnailInset * ( fittedRect. width / blurredThumbnailImage. size. width)
405405 c. draw ( blurredThumbnailImage. cgImage!, in: fittedRect. insetBy ( dx: - thumbnailScaledInset, dy: - thumbnailScaledInset) )
406+ } else if let thumbnailImage = thumbnailImage, let cgImage = thumbnailImage. 0 . cgImage, let cgImageAlpha = thumbnailImage. 1 . cgImage {
407+ c. setBlendMode ( . normal)
408+ c. interpolationQuality = . medium
409+ let mask = CGImage ( maskWidth: cgImageAlpha. width, height: cgImageAlpha. height, bitsPerComponent: cgImageAlpha. bitsPerComponent, bitsPerPixel: cgImageAlpha. bitsPerPixel, bytesPerRow: cgImageAlpha. bytesPerRow, provider: cgImageAlpha. dataProvider!, decode: nil , shouldInterpolate: true )
410+ c. draw ( cgImage. masking ( mask!) !, in: fittedRect)
406411 }
407412
408413 if let fullSizeImage = fullSizeImage, let cgImage = fullSizeImage. 0 . cgImage, let cgImageAlpha = fullSizeImage. 1 . cgImage {
@@ -420,7 +425,7 @@ public func chatMessageSticker(postbox: Postbox, userLocation: MediaResourceUser
420425 }
421426}
422427
423- public func chatMessageAnimatedSticker( postbox: Postbox , userLocation: MediaResourceUserLocation , file: TelegramMediaFile , small: Bool , size: CGSize , fitzModifier: EmojiFitzModifier ? = nil , fetched: Bool = false , onlyFullSize: Bool = false , thumbnail: Bool = false , synchronousLoad: Bool = false ) -> Signal < ( TransformImageArguments ) -> DrawingContext ? , NoError > {
428+ public func chatMessageAnimatedSticker( postbox: Postbox , userLocation: MediaResourceUserLocation , file: TelegramMediaFile , small: Bool , size: CGSize , fitzModifier: EmojiFitzModifier ? = nil , fetched: Bool = false , onlyFullSize: Bool = false , thumbnail: Bool = false , synchronousLoad: Bool = false , blurThumbnail : Bool = true ) -> Signal < ( TransformImageArguments ) -> DrawingContext ? , NoError > {
424429 let signal : Signal < Tuple3 < Data ? , Data ? , Bool > , NoError >
425430 if thumbnail {
426431 signal = chatMessageStickerThumbnailData ( postbox: postbox, userLocation: userLocation, file: file, synchronousLoad: synchronousLoad)
@@ -464,7 +469,7 @@ public func chatMessageAnimatedSticker(postbox: Postbox, userLocation: MediaReso
464469
465470 var blurredThumbnailImage : UIImage ?
466471 let thumbnailInset : CGFloat = 10.0
467- if let thumbnailImage = thumbnailImage {
472+ if blurThumbnail , let thumbnailImage = thumbnailImage {
468473 let thumbnailSize = thumbnailImage. 0 . size
469474 var thumbnailContextSize = thumbnailSize. aspectFitted ( CGSize ( width: 150.0 , height: 150.0 ) )
470475 let thumbnailDrawingSize = thumbnailContextSize
@@ -502,6 +507,11 @@ public func chatMessageAnimatedSticker(postbox: Postbox, userLocation: MediaReso
502507 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)
503508 let thumbnailScaledInset = thumbnailInset * ( fittedRect. width / blurredThumbnailImage. size. width)
504509 c. draw ( blurredThumbnailImage. cgImage!, in: thumbnailFittedRect. insetBy ( dx: - thumbnailScaledInset, dy: - thumbnailScaledInset) )
510+ } else if let thumbnailImage = thumbnailImage, let cgImage = thumbnailImage. 0 . cgImage, let cgImageAlpha = thumbnailImage. 1 . cgImage {
511+ c. setBlendMode ( . normal)
512+ c. interpolationQuality = . medium
513+ let mask = CGImage ( maskWidth: cgImageAlpha. width, height: cgImageAlpha. height, bitsPerComponent: cgImageAlpha. bitsPerComponent, bitsPerPixel: cgImageAlpha. bitsPerPixel, bytesPerRow: cgImageAlpha. bytesPerRow, provider: cgImageAlpha. dataProvider!, decode: nil , shouldInterpolate: true )
514+ c. draw ( cgImage. masking ( mask!) !, in: fittedRect)
505515 }
506516
507517 if let fullSizeImage = fullSizeImage, let cgImage = fullSizeImage. 0 . cgImage, let cgImageAlpha = fullSizeImage. 1 . cgImage {
0 commit comments