From 2d59a61a3f5bf853dfeb672d6493cd9ef35cc162 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Mon, 9 Oct 2023 00:32:11 +0900 Subject: [PATCH] Revert "Add notSkipAlphaChannel options." --- Source/APNGKit/APNGImageRenderer.swift | 12 ++---------- Source/APNGKit/APNGImageView.swift | 8 ++------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Source/APNGKit/APNGImageRenderer.swift b/Source/APNGKit/APNGImageRenderer.swift index 1390916..c689913 100644 --- a/Source/APNGKit/APNGImageRenderer.swift +++ b/Source/APNGKit/APNGImageRenderer.swift @@ -24,19 +24,11 @@ class APNGImageRenderer { private var foundMultipleAnimationControl: Bool = false private var expectedSequenceNumber: Int = 0 - init(decoder: APNGDecoder, shouldRenderWithAlpha: Bool = false) throws { + init(decoder: APNGDecoder) throws { self.decoder = decoder self.reader = try decoder.reader.clone() let imageHeader = decoder.imageHeader - - let bitmapInfo: CGBitmapInfo - if shouldRenderWithAlpha { - bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue) - } else { - bitmapInfo = imageHeader.bitmapInfo - } - guard let outputBuffer = CGContext( data: nil, width: imageHeader.width, @@ -44,7 +36,7 @@ class APNGImageRenderer { bitsPerComponent: imageHeader.bitDepthPerComponent, bytesPerRow: imageHeader.bytesPerRow, space: imageHeader.colorSpace, - bitmapInfo: bitmapInfo.rawValue + bitmapInfo: imageHeader.bitmapInfo.rawValue ) else { throw APNGKitError.decoderError(.canvasCreatingFailed) } diff --git a/Source/APNGKit/APNGImageView.swift b/Source/APNGKit/APNGImageView.swift index 3da9109..10f23a8 100644 --- a/Source/APNGKit/APNGImageView.swift +++ b/Source/APNGKit/APNGImageView.swift @@ -25,9 +25,6 @@ open class APNGImageView: PlatformView { /// of `self`. Default is `true`. open var autoStartAnimationWhenSetImage = true - /// Enable this option to always reference the alpha channel during rendering. Default is `false`. - open var shouldRenderWithAlpha = false - /// A delegate called every time when a "play" (a single loop of the animated image) is done. The parameter number /// is the count of played loops. /// @@ -98,10 +95,9 @@ open class APNGImageView: PlatformView { /// Creates an APNG image view with the specified animated image. /// - Parameter image: The initial image to display in the image view. - public convenience init(image: APNGImage?, autoStartAnimating: Bool = true, shouldRenderWithAlpha: Bool = false) { + public convenience init(image: APNGImage?, autoStartAnimating: Bool = true) { self.init(frame: .zero) self.autoStartAnimationWhenSetImage = autoStartAnimating - self.shouldRenderWithAlpha = shouldRenderWithAlpha self.image = image } @@ -216,7 +212,7 @@ open class APNGImageView: PlatformView { unsetImage() do { - renderer = try APNGImageRenderer(decoder: nextImage.decoder, shouldRenderWithAlpha: shouldRenderWithAlpha) + renderer = try APNGImageRenderer(decoder: nextImage.decoder) } catch { printLog("Error happens while creating renderer for image. \(error)") defaultDecodingErrored(