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

Invert colors snapshot method sometimes produces flipped image #56

Open
NickEntin opened this issue Apr 5, 2021 · 2 comments
Open

Invert colors snapshot method sometimes produces flipped image #56

NickEntin opened this issue Apr 5, 2021 · 2 comments
Assignees
Labels
bug Something isn't working as expected

Comments

@NickEntin
Copy link
Collaborator

No description provided.

@NickEntin NickEntin added the bug Something isn't working as expected label Apr 5, 2021
@NickEntin NickEntin self-assigned this Apr 5, 2021
@NickEntin
Copy link
Collaborator Author

@joshmsamuels I have a theory what's happening here, but I can't get it to reproduce locally right now. Can you try making this change locally and let me know which path it's taking (is the image backed by a CIImage or CGImage)?

--- a/Sources/AccessibilitySnapshot/Core/Swift/Classes/UIView+InvertColorsSnapshotting.swift
+++ b/Sources/AccessibilitySnapshot/Core/Swift/Classes/UIView+InvertColorsSnapshotting.swift
@@ -37,8 +37,15 @@ extension UIView {
                 drawHierarchy(in: bounds, afterScreenUpdates: true)
             }

+            let inputImage: CIImage
+            if let image = image.ciImage {
+                inputImage = image
+            } else {
+                inputImage = CIImage(cgImage: image.cgImage!)
+            }
+
             let filter = CIFilter(name: "CIColorInvert")!
-            filter.setValue(image.ciImage ?? CIImage(cgImage: image.cgImage!), forKey: kCIInputImageKey)
+            filter.setValue(inputImage, forKey: kCIInputImageKey)
             let ciContext = CIContext(cgContext: context.cgContext, options: nil)
             let invertedCIImage = filter.outputImage!
             let invertedCGImage = ciContext.createCGImage(invertedCIImage, from: invertedCIImage.extent)!

@joshmsamuels
Copy link
Collaborator

I am getting the else case locally. Is that the expected behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants