Hi everyone, I've hit a roadblock in my project 13 when playing around with new topics, when I select the image using the PhotosPicker it shows up just fine:
func loadImage() {
Task {
do {
guard let imageData = try await selectedItem?.loadTransferable(type: Data.self) else { return }
guard let inputUiImage = UIImage(data: imageData) else { return }
inputTestUIImage = inputUiImage
image = Image(uiImage: inputUiImage) // gets displayed in a view just right
ciImage = CIImage(image: inputUiImage)
} catch {
print(error)
}
}
}
I've stripped down the processing code and just left the conversion, but basically when I run processImage(), it flips an iPhone photo randomly:
func processImage() {
ciImage = CIImage(image: inputTestUIImage!)
guard let cgImage = CIContext().createCGImage(ciImage!, from: ciImage!.extent) else { return }
let outputUiImage = UIImage(cgImage: cgImage)
let imageOutput = Image(uiImage: outputUiImage)
image = imageOutput
}
}
(Don't mind force unwrapping, it's my testing code.)
You can see it clear when using that flower photo captured on the iPhone X in simulator:
(Click here if the image doesn't show up)
Any thoughts and help would be appreciated!