示例#1
0
        /// <devdoc>
        ///     Copy the native GDI+ EncoderParameters data from a chunk of memory into a managed EncoderParameters object.
        ///     See ConvertToMemory for more info.
        /// </devdoc>
        internal static EncoderParameters ConvertFromMemory(IntPtr memory)
        {
            if (memory == IntPtr.Zero)
            {
                throw SafeNativeMethods.Gdip.StatusException(SafeNativeMethods.Gdip.InvalidParameter);
            }

            int count = Marshal.ReadIntPtr(memory).ToInt32();

            EncoderParameters p = new EncoderParameters(count);
            int  size           = Marshal.SizeOf(typeof(EncoderParameter));
            long arrayOffset    = (long)memory + Marshal.SizeOf(typeof(IntPtr));

            for (int i = 0; i < count; i++)
            {
                Guid guid                      = (Guid)UnsafeNativeMethods.PtrToStructure((IntPtr)(i * size + arrayOffset), typeof(Guid));
                int  numberOfValues            = Marshal.ReadInt32((IntPtr)(i * size + arrayOffset + 16));
                EncoderParameterValueType type = (EncoderParameterValueType)Marshal.ReadInt32((IntPtr)(i * size + arrayOffset + 20));
                IntPtr value                   = Marshal.ReadIntPtr((IntPtr)(i * size + arrayOffset + 24));

                p._param[i] = new EncoderParameter(new Encoder(guid), numberOfValues, type, value);
            }

            return(p);
        }
示例#2
0
        private int _GetPointId(IntPtr pointCloudHandle, int index)
        {
            IntPtr pointCloudIdsHandle = IntPtr.Zero;

            ExternApi.ArPointCloud_getPointIds(m_NativeSession.SessionHandle, pointCloudHandle,
                                               ref pointCloudIdsHandle);
            IntPtr pointIdHandle = new IntPtr(pointCloudIdsHandle.ToInt64() + (Marshal.SizeOf(typeof(int)) * index));

            return(Marshal.ReadInt32(pointIdHandle));
        }
        public static void Write(this IStream stream, byte[] pv, int cb, out int pcbWritten)
        {
            var pcbWrittenPtr = Marshal.AllocCoTaskMem(4);

            try
            {
                stream.Read(pv, cb, pcbWrittenPtr);
                pcbWritten = Marshal.ReadInt32(pcbWrittenPtr);
            }
            finally
            {
                Marshal.FreeCoTaskMem(pcbWrittenPtr);
            }
        }