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 wish to invert the colours such that the tiny ensuing picture is white textual content on a black background. I’ve tried numerous strategies from stackoverflow to invert the colours however every ends in a clean outcome. I am pretty new to Swift and iOS growth, whats the simplest option to invert the colours of that smaller outcome picture?

      Button(motion: {
        guard let picture = ImageRenderer(content material: canvas).uiImage else {
          // didn't 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]

Leave a Reply

Your email address will not be published. Required fields are marked *