I’ve been attempting to flood fill an image using vImageFloodFill_ARGB8888 and it won’t work. There’s not way to set the threshold for minute color difference so the fill actually fills. Sop I thought that
vImageFloodFill_Planar16U(const vImage_Buffer *srcDest, void *tempBuffer, vImagePixelCount seedX, vImagePixelCount seedY, Pixel_16U newValue, int connectivity, vImage_Flags flags);
might work for my needs but I cannot for the life of me figure out how to pass this value Pixel_16U newValue
I’ve tried converting the rgba UInt8 values several ways and there simple does not seem to be a way I can come up with to make it work I keep getting and error that I’m passing the wrong value. I’ve even tried chatgpt but it doesn’t work.
with vImageFloodFill_ARGB8888 I can pass the replacement color as an array of UInt8 values if I just do &replacementColor but if I attempt to convert that array to UInt16 values it doesn’t work the same way
var rgbaComponents: [UInt16] = [UInt16(replacementRGBA.0), UInt16(replacementRGBA.1), UInt16(replacementRGBA.2), UInt16(replacementRGBA.3)]
vImageFloodFill_Planar16U(&buffer, &maskBuffer, vImagePixelCount(seedPoint.x), vImagePixelCount(seedPoint.y), rgbaComponents, 8, vImage_Flags(kvImageNoFlags))
gives the error : Cannot convert value of type ‘[UInt16]’ to expected argument type ‘Pixel_16U’ (aka ‘UInt16’)
I just need a flood fill function. I’ve tried every piece of code I could find here, and through chatgpt and even a direct cut and paste of apple’s sample code for doing flood fill and nothing works. I either get too little fill or as in this question I get nowhere because I can’t figure out how to pass the value
April G is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.