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 end result. I am pretty new to Swift and iOS improvement, whats the simplest solution to invert the colours of that smaller end result 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]

Leave a Reply