MultiK2/BodyIndexFrameReader.cs
/// <summary>
/// For DEBUG purposes only. Implementation / Output may change in the future.
/// </summary>
For DEBUG purposes only. Implementation / Output may change in the future.
For DEBUG purposes only . Implementation / Output may change in the future .
public unsafe SoftwareBitmap GetDisplayableBitmap()
        {   
            var targetBitmap = new SoftwareBitmap(BitmapPixelFormat.Bgra8, Bitmap.PixelWidth, Bitmap.PixelHeight, BitmapAlphaMode.Ignore);
            using (var sourceBuffer = Bitmap.LockBuffer(BitmapBufferAccessMode.Read))
            using (var targetBuffer = targetBitmap.LockBuffer(BitmapBufferAccessMode.Write))
            using (var sourceBufferRef = sourceBuffer.CreateReference())
            using (var targetBufferRef = targetBuffer.CreateReference())
            {
                byte* sourcePtr;
                uint sourceCapacity;
                byte* targetPtr;
                uint targetCapacity;
                ((IMemoryBufferByteAccess)sourceBufferRef).GetBuffer(out sourcePtr, out sourceCapacity);
                ((IMemoryBufferByteAccess)targetBufferRef).GetBuffer(out targetPtr, out targetCapacity);
                uint* targetDataPtr = (uint*)targetPtr;
                for (var i = 0; i < sourceCapacity; i++)
                {
                    byte index = sourcePtr[i];
                    targetDataPtr[i] = index == 0xff ? 0 : ColorMap[index];                                        
                }
            }
            return targetBitmap;
        }
public unsafe SoftwareBitmap GetDisplayableBitmap ( ) { var targetBitmap = new SoftwareBitmap ( BitmapPixelFormat . Bgra8 , Bitmap . PixelWidth , Bitmap . PixelHeight , BitmapAlphaMode . Ignore ) ; using ( var sourceBuffer = Bitmap . LockBuffer ( BitmapBufferAccessMode . Read ) ) using ( var targetBuffer = targetBitmap . LockBuffer ( BitmapBufferAccessMode . Write ) ) using ( var sourceBufferRef = sourceBuffer . CreateReference ( ) ) using ( var targetBufferRef = targetBuffer . CreateReference ( ) ) { byte * sourcePtr ; uint sourceCapacity ; byte * targetPtr ; uint targetCapacity ; ( ( IMemoryBufferByteAccess ) sourceBufferRef ) . GetBuffer ( out sourcePtr , out sourceCapacity ) ; ( ( IMemoryBufferByteAccess ) targetBufferRef ) . GetBuffer ( out targetPtr , out targetCapacity ) ; uint * targetDataPtr = ( uint * ) targetPtr ; for ( var i = 0 ; i < sourceCapacity ; i ++ ) { byte index = sourcePtr [ i ] ; targetDataPtr [ i ] = index == 0xff ? 0 : ColorMap [ index ] ; } } return targetBitmap ; }
For DEBUG purposes only.
For DEBUG purposes only .