Example #1
0
        public static VTStatus ToCGImage(this CVPixelBuffer pixelBuffer, out CGImage?image)
        {
            if (pixelBuffer is null)
            {
                throw new ArgumentNullException(nameof(pixelBuffer));
            }

            var ret = VTCreateCGImageFromCVPixelBuffer(pixelBuffer.GetCheckedHandle(),
                                                       IntPtr.Zero, // no options as of 9.0/10.11 - always pass NULL
                                                       out var imagePtr);

            image = Runtime.GetINativeObject <CGImage> (imagePtr, true);            // This is already retained CM_RETURNS_RETAINED_PARAMETER

            return(ret);
        }