UnsafeMutablePointer<UInt16>.allocate(capacity: totalPixels) is returning 0 in swift 3

138 Views Asked by At

hello i have the following code:

totalPixels = imageHeight * imageWidth
regionsData = UnsafeMutablePointer<UInt16>.allocate(capacity: totalPixels)
let pixelColor = regionsData.advanced(by: (pixelY * imageWidth) + pixelX).pointee

where pixelColor is returning 0, this is supposed to color parts of an image when i tap on the screen, but for some reason it is not working, and of course i think the reason is because pixelColor = 0 and note that the other values are not 0 (totalPixels, pixelY, pixelX, ...) any help is appreciated.

0

There are 0 best solutions below