Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add notSkipAlphaChannel options." #137

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions Source/APNGKit/APNGImageRenderer.swift
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading