How does one access bytes (or Int16\'s, floats, etc.) out of memory pointed to by an UnsafeMutableRawPointer (new in Swift 3) handed to a Swift function by a C API (Core Aud
Create Data object.
init(bytesNoCopy bytes: UnsafeMutableRawPointer, count: Int, deallocator: Data.Deallocator)
One important way missing from the other answers here is initialising a Data object with UnsafeMutableRawPointer. The data object can then be used for other calculations.
public func base64(quality: Int32 = 67) -> String? {
var size: Int32 = 0
if let image = gdImageJpegPtr(internalImage, &size, quality) {
// gdImageJpegPtr returns an UnsafeMutableRawPointer that is converted to a Data object
let d = Data(bytesNoCopy: image, count: Int(size), deallocator: .none)
return d.base64EncodedString()
}
return nil
}