Skip to content

Commit

Permalink
Revert "Add notSkipAlphaChannel options."
Browse files Browse the repository at this point in the history
  • Loading branch information
onevcat committed Oct 8, 2023
1 parent 0e8bd63 commit 2d59a61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
12 changes: 2 additions & 10 deletions Source/APNGKit/APNGImageRenderer.swift
Expand Up @@ -24,27 +24,19 @@ 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,
height: imageHeader.height,
bitsPerComponent: imageHeader.bitDepthPerComponent,
bytesPerRow: imageHeader.bytesPerRow,
space: imageHeader.colorSpace,
bitmapInfo: bitmapInfo.rawValue
bitmapInfo: imageHeader.bitmapInfo.rawValue
) else {
throw APNGKitError.decoderError(.canvasCreatingFailed)
}
Expand Down
8 changes: 2 additions & 6 deletions Source/APNGKit/APNGImageView.swift
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 2d59a61

Please sign in to comment.