當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。