vImageFloodFill_ARGB8888(_:_:_:_:_:_:_:) replacing ALL pixels in image, not just adjacent ones

54 Views Asked by At

Xcode Version 14.1 beta 3 (14B5033e)

https://developer.apple.com/documentation/accelerate/vimage/vimage_operations/applying_a_flood_fill_to_an_image/applying_flood_fills_to_an_image

I have two changes from the example code:

  1. let image = imageLiteral(resourceName: "simon.png").cgImage( forProposedRect: nil, context: nil, hints: nil)!

I could not get that line to compile, so I used:

guard let inputCGImage = img.cgImage else { print("Can't create input CGImage") return }

2.vImageFloodFill_ARGB8888(src, tmp, seedX, seedY, &newARGB, 8, 0) I saw no variable named tmp created, and according to the documentation on the method (vImageFloodFill_ARGB8888) the tmp buffer will be created if you pass a nil. So I pass nil on that line.

I also wrap the whole thing in some display code to show an image, allow a tap, and apply the flood fill, return a new image, and display that.

Unfortunately... I get a single colored square (the size of the original image), not an image with a portion replaced with a new color.

0

There are 0 best solutions below