Ejemplo n.º 1
0
        public static void Write(this GraphicBuffer buffer, byte[] data, int offset, int bytes, bool discard = true)
        {
            GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);

            unsafe
            {
                var ptr = ClrRuntime.Runtime.GetPointer(data, 0);
                try
                {
                    buffer.Write(ptr, offset, bytes, discard);
                }

                finally
                {
                    handle.Free();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data">array</param>
        /// <param name="offset">Offset in bytes to start writing</param>
        public static void Write <T>(this GraphicBuffer buffer, T[] data, int offset = 0, bool discard = true)
            where T : struct
        {
            unsafe
            {
                GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
                var      ptr    = ClrRuntime.Runtime.GetPointer(data, 0);

                try
                {
                    buffer.Write(ptr, offset, ClrRuntime.Runtime.SizeOf <T>() * data.Length, discard);
                }

                finally
                {
                    handle.Free();
                }
            }
        }