Monday, October 5, 2026
HomeiOS Developmentios - Invert picture captured from ImageRenderer

ios – Invert picture captured from ImageRenderer

[ad_1]

I’ve a picture (outlined in pink) displaying the results of ImageRenderer referred to as on a canvas. I need to invert the colours such that the tiny ensuing picture is white textual content on a black background. I’ve tried varied strategies from stackoverflow to invert the colours however every leads to a clean consequence. I am pretty new to Swift and iOS growth, whats the simplest technique to invert the colours of that smaller consequence picture?

      Button(motion: {
        guard let picture = ImageRenderer(content material: canvas).uiImage else {
          // did not render view as picture
          return
        }
        UIImageWriteToSavedPhotosAlbum(picture, nil, nil, nil)
        resultImage = Picture(uiImage: picture)
      }){
        Textual content("Analyze")
      }

Image of simulator showing canvas view and smaller view of the image derived from the canvas drawing

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments