当前位置: 首页>>代码示例>>C#>>正文


C# IntPtr.ToPointer方法代码示例

本文整理汇总了C#中System.IntPtr.ToPointer方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.ToPointer方法的具体用法?C# IntPtr.ToPointer怎么用?C# IntPtr.ToPointer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IntPtr的用法示例。


在下文中一共展示了IntPtr.ToPointer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTypeHelper

        [System.Security.SecuritySafeCritical]  // auto-generated
        internal unsafe static Type GetTypeHelper(Type typeStart, Type[] genericArgs, IntPtr pModifiers, int cModifiers)
        {
            Type type = typeStart;

            if (genericArgs != null)
            {
                type = type.MakeGenericType(genericArgs);
            }

            if (cModifiers > 0)
            {
                int* arModifiers = (int*)pModifiers.ToPointer();
                for(int i = 0; i < cModifiers; i++)
                {
                    if ((CorElementType)Marshal.ReadInt32((IntPtr)arModifiers, i * sizeof(int)) == CorElementType.Ptr)
                        type = type.MakePointerType();
                    
                    else if ((CorElementType)Marshal.ReadInt32((IntPtr)arModifiers, i * sizeof(int)) == CorElementType.ByRef)
                        type = type.MakeByRefType();

                    else if ((CorElementType)Marshal.ReadInt32((IntPtr)arModifiers, i * sizeof(int)) == CorElementType.SzArray)
                        type = type.MakeArrayType();

                    else
                        type = type.MakeArrayType(Marshal.ReadInt32((IntPtr)arModifiers, ++i * sizeof(int)));
                }
            }
            
            return type;
        }
开发者ID:jashook,项目名称:coreclr,代码行数:31,代码来源:RuntimeHandles.cs

示例2: FMOD_EVENT_CALLBACK

        private static FMOD.RESULT FMOD_EVENT_CALLBACK(IntPtr eventraw, FMOD.EVENT_CALLBACKTYPE type, IntPtr param1, IntPtr param2, IntPtr userdata)
        {
            unsafe
            {
                switch (type)
                {
                    case FMOD.EVENT_CALLBACKTYPE.SOUNDDEF_CREATE :
                    {
                        int entryindex   = *(int*)param2.ToPointer() ;     // [in]  (int) index of sound definition entry
                        uint *realpointer = (uint *)param2.ToPointer();    // [out] (FMOD::Sound *) a valid lower level API FMOD Sound handle

                        FMOD.Sound s = null;
                        fsb.getSubSound(entryindex, ref s);

                        *realpointer = (uint)s.getRaw().ToPointer();

                        break;
                    }

                    case FMOD.EVENT_CALLBACKTYPE.SOUNDDEF_RELEASE :
                    {
                        break;
                    }
                }

            }
            return FMOD.RESULT.OK;
        }
开发者ID:sanyaade,项目名称:vsxu-dirty,代码行数:28,代码来源:programmer_sound.cs

示例3: ConvertToNative

 internal static unsafe IntPtr ConvertToNative(string strManaged, IntPtr pNativeBuffer)
 {
     byte num;
     byte* numPtr;
     if (strManaged == null)
     {
         return IntPtr.Zero;
     }
     System.StubHelpers.StubHelpers.CheckStringLength(strManaged.Length);
     bool flag = strManaged.TryGetTrailByte(out num);
     uint len = (uint) (strManaged.Length * 2);
     if (flag)
     {
         len++;
     }
     if (pNativeBuffer != IntPtr.Zero)
     {
         *((int*) pNativeBuffer.ToPointer()) = len;
         numPtr = (byte*) (pNativeBuffer.ToPointer() + 4);
     }
     else
     {
         numPtr = (byte*) Win32Native.SysAllocStringByteLen(null, len).ToPointer();
     }
     fixed (char* str = ((char*) strManaged))
     {
         char* chPtr = str;
         Buffer.memcpyimpl((byte*) chPtr, numPtr, (strManaged.Length + 1) * 2);
     }
     if (flag)
     {
         numPtr[len - 1] = num;
     }
     return (IntPtr) numPtr;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:BSTRMarshaler.cs

示例4: InterlockedExchangePointer

 internal static unsafe IntPtr InterlockedExchangePointer(IntPtr lpAddress, IntPtr lpValue)
 {
     IntPtr ptr2;
     IntPtr ptr = *((IntPtr*) lpAddress.ToPointer());
     do
     {
         ptr2 = ptr;
         ptr = Interlocked.CompareExchange(ref (IntPtr) ref lpAddress.ToPointer(), lpValue, ptr2);
     }
     while (ptr != ptr2);
     return ptr;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:SafeNativeMethods.cs

示例5: InterlockedExchangePointer

        static internal unsafe IntPtr InterlockedExchangePointer(
                IntPtr lpAddress,
                IntPtr lpValue)
        {
            IntPtr  previousPtr;
            IntPtr  actualPtr = *(IntPtr *)lpAddress.ToPointer();

            do {
                previousPtr = actualPtr;
                actualPtr   = Interlocked.CompareExchange(ref *(IntPtr *)lpAddress.ToPointer(), lpValue, previousPtr);
            }
            while (actualPtr != previousPtr);

            return actualPtr;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:15,代码来源:SafeNativeMethods.cs

示例6: RioConnectionOrientedSocket

 internal RioConnectionOrientedSocket(IntPtr overlapped, IntPtr adressBuffer, RioConnectionOrientedSocketPool pool, RioFixedBufferPool sendBufferPool, RioFixedBufferPool receiveBufferPool,
     uint maxOutstandingReceive, uint maxOutstandingSend, IntPtr SendCompletionQueue, IntPtr ReceiveCompletionQueue) :
     base(sendBufferPool, receiveBufferPool, maxOutstandingReceive, maxOutstandingSend, SendCompletionQueue, ReceiveCompletionQueue,
         ADDRESS_FAMILIES.AF_INET, SOCKET_TYPE.SOCK_STREAM, PROTOCOL.IPPROTO_TCP)
 {
     _overlapped = (RioNativeOverlapped*)overlapped.ToPointer();
     _eventHandle = Kernel32.CreateEvent(IntPtr.Zero, false, false, null);
     _adressBuffer = adressBuffer;
     _pool = pool;
     unsafe
     {
         var n = (NativeOverlapped*)overlapped.ToPointer();
         n->EventHandle = _eventHandle;
     }
 }
开发者ID:xiaomiwk,项目名称:Cowboy,代码行数:15,代码来源:RioConnectionOrientedSocket.cs

示例7: RecognizeByte

 protected override void RecognizeByte(uint lastVertexId, IntPtr pointer, OneIndexBuffer oneIndexBuffer, List<RecognizedPrimitiveInfo> primitiveInfoList, uint primitiveRestartIndex)
 {
     int length = oneIndexBuffer.Length;
     unsafe
     {
         var array = (byte*)pointer.ToPointer();
         long nearestRestartIndex = -1;
         uint i = 0;
         while (i < length && array[i] == primitiveRestartIndex)
         { nearestRestartIndex = i; i++; }
         for (i = i + 2; i < length; i++)
         {
             var value = array[i];
             if (value == primitiveRestartIndex)
             {
                 // try the loop back line.
                 nearestRestartIndex = i;
             }
             else if (value == lastVertexId
                 && array[i - 1] != primitiveRestartIndex
                 && array[nearestRestartIndex + 1] != primitiveRestartIndex
                 && nearestRestartIndex + 2 < i)
             {
                 var item = new RecognizedPrimitiveInfo(i, array[nearestRestartIndex + 1], array[i - 1], lastVertexId);
                 primitiveInfoList.Add(item);
             }
         }
     }
 }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:29,代码来源:TriangleFanRecognizer.cs

示例8: CreateHistogram

        protected unsafe void CreateHistogram(IntPtr sourceData, int width, int height)
        {
            try
            {
                this.histogram.Reset();

                int points = 0;
                var pDepth = (ushort*)sourceData.ToPointer();
                for (int y = 0; y < height; ++y)
                {
                    for (int x = 0; x < width; ++x, ++pDepth)
                    {
                        ushort depthVal = *pDepth;
                        if (depthVal > 0)
                        {
                            this.histogram.Increase(depthVal);
                            points++;
                        }
                    }
                }
                this.histogram.PostProcess(points);
            }
            catch (AccessViolationException)
            { }
            catch (SEHException)
            { }
        }
开发者ID:aabrohi,项目名称:kinect-kollage,代码行数:27,代码来源:DepthImageFactoryBase.cs

示例9: VertexBuffer

        public VertexBuffer(int vertexCapacity, int indexCapacity)
        {
            declarations = new List<VertexDeclaration>();

            int tmp;
            GL.GenVertexArrays(1, out tmp);
            VertexArrayObject = tmp;
            GL.BindVertexArray(VertexArrayObject);

            GL.GenBuffers(1, out tmp);
            VertexDataBufferObject = tmp;

            GL.GenBuffers(1, out tmp);
            IndexDataBufferObject = tmp;

            UsageMode = BufferUsageHint.DynamicDraw;

            vertexDataLength = vertexCapacity;
            indexDataLength = indexCapacity;

            _indexDataPointer = Marshal.AllocHGlobal(indexDataLength * sizeof(int));
            IndexData = (int*)_indexDataPointer.ToPointer();

            _vertexDataPointer = Marshal.AllocHGlobal(vertexDataLength * sizeof(float));
            VertexData = (float*)_vertexDataPointer.ToPointer();

            voffset = 0;
            ioffset = 0;
            stride = 0;
        }
开发者ID:remy22,项目名称:BlueberryEngine,代码行数:30,代码来源:VertexBuffer.cs

示例10: BloomFilter

 public BloomFilter(IntPtr storage, long storageSize, IEnumerable<IHasher> hashes)
 {
     //TODO force Int32 alignment for storage
     _storageSize = storageSize - 1; //last int is used to hold count of writes
     _hashes = hashes.ToArray();
     _storage = (Int32*) storage.ToPointer();
 }
开发者ID:TonyAbell,项目名称:bloomburger,代码行数:7,代码来源:BloomFilter.cs

示例11: READCALLBACK

        /// <summary>
        /// Readcallback
        /// </summary>
        /// <param name="dsp_state"></param>
        /// <param name="inbuf"></param>
        /// <param name="outbuf"></param>
        /// <param name="length"></param>
        /// <param name="inchannels"></param>
        /// <param name="outchannels"></param>
        /// <returns></returns>
        private static FMOD.RESULT READCALLBACK(ref FMOD.DSP_STATE dsp_state, IntPtr inbuf, IntPtr outbuf, uint length, int inchannels, int outchannels)
        {
            uint count = 0;
            int count2 = 0;
            IntPtr thisdspraw = dsp_state.instance;

            thisdsp.setRaw(thisdspraw);

            unsafe
            {
                float* inbuffer = (float*)inbuf.ToPointer();
                float* outbuffer = (float*)outbuf.ToPointer();

                for (count = 0; count < length; count++)
                {
                    for (count2 = 0; count2 < outchannels; count2++)
                    {
                        outbuffer[(count * outchannels) + count2] = inbuffer[(count * inchannels) + count2];
                    }
                    bpm.AddSample(inbuffer[(count * inchannels)] * 32767.0f);
                }
            }

            return FMOD.RESULT.OK;
        }
开发者ID:olbers,项目名称:sauip4,代码行数:35,代码来源:PlayListBuilder.cs

示例12: FindPointsWithinDepthRange

        protected override unsafe IList<Point> FindPointsWithinDepthRange(IntPtr dataPointer)
        {
            var result = new List<Point>();
            ushort* pDepth = (ushort*)dataPointer.ToPointer();

            int localHeight = this.Size.Height; //5ms faster when it's a local variable
            int localWidth = this.Size.Width;
            int maxY = localHeight - this.settings.LowerBorder;
            int minDepth = this.settings.MinimumDepthThreshold;
            int maxDepth = this.settings.MaximumDepthThreshold;

            for (int y = 0; y < localHeight; y++)
            {
                for (int x = 0; x < localWidth; x++)
                {
                    ushort depthValue = *pDepth;
                    if (depthValue > 0 && y < maxY && depthValue <= maxDepth && depthValue >= minDepth) //Should not be put in a seperate method for performance reasons
                    {
                        if (this.filterVolumes.Count == 0 || this.filterVolumes.Any(f => f.Contains(x, y, depthValue)))
                        {
                            result.Add(new Point(x, y, depthValue));
                        }
                    }
                    pDepth++;
                }
            }
            return result;
        }
开发者ID:aabrohi,项目名称:kinect-kollage,代码行数:28,代码来源:VolumeFilterClusterDataSource.cs

示例13: MemoryMappedTexture32bpp

 /// <summary>
 /// Initializes a new instance of the <see cref="MemoryMappedTexture32bpp"/> class.
 /// </summary>
 /// <param name="size">The total size of the texture.</param>
 public MemoryMappedTexture32bpp(Size2 size)
 {
     m_pointer = Marshal.AllocHGlobal(size.Width * size.Height * 4);
     m_pointerNative = (int*)m_pointer.ToPointer();
     m_size = size;
     m_countInts = m_size.Width * m_size.Height;
 }
开发者ID:jtpgames,项目名称:Kinect-Recorder,代码行数:11,代码来源:MemoryMappedTexture32bpp.cs

示例14: DecodeYV12ToGreyBytes

        /// <summary>
        /// 将YV12流转换成灰度二维矩阵
        /// </summary>
        /// <param name="pIn"></param>
        /// <param name="bytesOut"></param>
        /// <returns></returns>
        public static long DecodeYV12ToGreyBytes(IntPtr pIn, byte[,] bytesOut)
        {
            CheckOutput(bytesOut, "DecodeYV12ToGreyBytes");

            Stopwatch watch = Stopwatch.StartNew();

            unsafe
            {
                byte* yData = (byte*)pIn.ToPointer();
                lock (bytesOut)
                {
                    int W = bytesOut.GetLength(0);
                    int H = bytesOut.GetLength(1);
                    for (int h = 0; h < H; h++)
                    {
                        for (int w = 0; w < W; w++)
                        {
                            bytesOut[w, h] = yData[h * W + w];
                        }
                    }
                }
            }

            return watch.ElapsedMilliseconds;
        }
开发者ID:dalinhuang,项目名称:forest-fire-prevention-framework,代码行数:31,代码来源:YV12.cs

示例15: CallBack

 internal unsafe PortAudio.PaStreamCallbackResult CallBack(IntPtr inputBuffer, IntPtr outputBuffer,
     uint framesPerBuffer, ref PortAudio.PaStreamCallbackTimeInfo timeInfo,
     PortAudio.PaStreamCallbackFlags statusFlags, IntPtr userData)
 {
     CallBack(framesPerBuffer, (float*)outputBuffer.ToPointer());
     return PortAudio.PaStreamCallbackResult.paContinue;
 }
开发者ID:NuzzIndustries,项目名称:SoundGenerator,代码行数:7,代码来源:SoundEffect.cs


注:本文中的System.IntPtr.ToPointer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。