I’m trying to implement still picture capture with AVFoundation and believe I am close, however I am unsure how to translate the following line of code into Xojo:

[output setOutputSettings: @{(id)kCVPixelBufferPixelFormatTypeKey: @(k32BGRAPixelFormat)}]

So far I have the following:

dim dictionaryPtr as ptr = NSClassFromString("NSDictionary") declare function dictionaryWithObject lib CocoaLib selector "dictionaryWithObject:forKey:" (clsRef as ptr, obj as CFStringRef, key as CFStringRef) as ptr //<-- is key the right type? declare sub setOutputSettings lib CocoaLib selector "setOutputSettings:" (obj_id as ptr, settings as ptr) dim outputSettingsDictionary as ptr = dictionaryWithObject(dictionaryPtr,k32BGRAPixelFormat,kCVPixelBufferPixelFormatTypeKey) setOutputSettings(output, outputSettingsDictionary) //<-- this line triggers the exception below
Where k32BGRAPixelFormat is a constant with a value of ‘BGRA’ (found that one in the apple docs). I made kCVPixelBufferPixelFormatTypeKey a constant as well but executing that line of code yields an objective-c exception:

Exception Message: *** -[AVCaptureStillImageOutput setOutputSettings:] - { kCVPixelBufferPixelFormatTypeKey = BGRA; } is not a supported.
Anyone have any ideas on how to translate the “(id)kCVPixelBufferPixelFormatTypeKey”? In the apple docs its defined as

const CFStringRef  kCVPixelBufferPixelFormatTypeKey ;

But I’m not sure how to obtain the value to use in my code. Any help is appreciated :slight_smile: