Invert colors snapshot method sometimes produces flipped image
NickEntin opened this issue · comments
@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)!
I am getting the else case locally. Is that the expected behaviour?