Пример #1
0
        public CVPixelBuffer(int width, int height, CVPixelFormatType pixelFormatType, NSDictionary pixelBufferAttributes)
        {
            if (width <= 0)
            {
                throw new ArgumentOutOfRangeException("width");
            }

            if (height <= 0)
            {
                throw new ArgumentOutOfRangeException("height");
            }

            IntPtr   pixelBufferOut = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
            CVReturn ret            = CVPixelBufferCreate(IntPtr.Zero, (IntPtr)width, (IntPtr)height, pixelFormatType,
                                                          pixelBufferAttributes == null ? IntPtr.Zero : pixelBufferAttributes.Handle, pixelBufferOut);

            if (ret != CVReturn.Success)
            {
                Marshal.FreeHGlobal(pixelBufferOut);
                throw new ArgumentException(ret.ToString());
            }

            this.handle = Marshal.ReadIntPtr(pixelBufferOut);
            Marshal.FreeHGlobal(pixelBufferOut);
        }
Пример #2
0
        public CVPixelBufferPool(NSDictionary poolAttributes, NSDictionary pixelBufferAttributes)
        {
            CVReturn ret = CVPixelBufferPoolCreate(IntPtr.Zero, poolAttributes.GetHandle(),
                                                   pixelBufferAttributes.GetHandle(), out handle);

            if (ret != CVReturn.Success)
            {
                throw new Exception("CVPixelBufferPoolCreate returned " + ret.ToString());
            }
        }
Пример #3
0
        public CVPixelBuffer CreatePixelBuffer()
        {
            IntPtr   pixelBufferOut;
            CVReturn ret = CVPixelBufferPoolCreatePixelBuffer(IntPtr.Zero, handle, out pixelBufferOut);

            if (ret != CVReturn.Success)
            {
                throw new Exception("CVPixelBufferPoolCreatePixelBuffer returned " + ret.ToString());
            }

            return(new CVPixelBuffer(pixelBufferOut, true));
        }
Пример #4
0
        CVPixelBuffer(nint width, nint height, CVPixelFormatType pixelFormatType, NSDictionary pixelBufferAttributes)
        {
            if (width <= 0)
                throw new ArgumentOutOfRangeException ("width");

            if (height <= 0)
                throw new ArgumentOutOfRangeException ("height");

            CVReturn ret = CVPixelBufferCreate (IntPtr.Zero, width, height, pixelFormatType,
                pixelBufferAttributes == null ? IntPtr.Zero : pixelBufferAttributes.Handle, out handle);

            if (ret != CVReturn.Success)
                throw new ArgumentException (ret.ToString ());
        }
Пример #5
0
        public CVPixelBufferPool(NSDictionary poolAttributes, NSDictionary pixelBufferAttributes)
        {
            IntPtr   poolOut = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
            CVReturn ret     = CVPixelBufferPoolCreate(IntPtr.Zero, poolAttributes.Handle, pixelBufferAttributes.Handle, poolOut);

            if (ret != CVReturn.Success)
            {
                Marshal.FreeHGlobal(poolOut);
                throw new Exception("CVPixelBufferPoolCreate returned " + ret.ToString());
            }

            this.handle = Marshal.ReadIntPtr(poolOut);
            Marshal.FreeHGlobal(poolOut);
        }
Пример #6
0
        public CVPixelBuffer CreatePixelBuffer()
        {
            IntPtr   pixelBufferOut = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(IntPtr)));
            CVReturn ret            = CVPixelBufferPoolCreatePixelBuffer(IntPtr.Zero, handle, pixelBufferOut);

            if (ret != CVReturn.Success)
            {
                Marshal.FreeHGlobal(pixelBufferOut);
                throw new Exception("CVPixelBufferPoolCreatePixelBuffer returned " + ret.ToString());
            }

            CVPixelBuffer pixelBuffer = new CVPixelBuffer(Marshal.ReadIntPtr(pixelBufferOut));

            Marshal.FreeHGlobal(pixelBufferOut);
            return(pixelBuffer);
        }