Exemple #1
0
        UInt32[] ReadDataBinaryReader(BinaryReader data, int itemCount)
        {
            UInt32[] outData = new UInt32[itemCount];

            for (int i = 0; i < itemCount; ++i)
            {
                outData[i] = BinaryUtilities.SwapUInt32(data.ReadUInt32());
            }
            return(outData);
        }
Exemple #2
0
        public static UInt32 ReadUInt32Unsafe(this byte[] buff, int offset)
        {
            unsafe
            {
                fixed(byte *start = buff)
                {
                    UInt32 *current = (UInt32 *)(start + offset);

                    return(BinaryUtilities.SwapUInt32(*current));
                }
            }
        }
Exemple #3
0
        UInt32[] BitConverterStandaloneSwap(MemoryStream data, int itemCount)
        {
            UInt32[] outData = new UInt32[itemCount];

            var buff  = data.GetBuffer();
            int start = (int)data.Position;

            for (int i = 0; i < itemCount; ++i)
            {
                outData[i] = BinaryUtilities.SwapUInt32(BitConverter.ToUInt32(buff, start + (i * 4)));
            }
            data.Position += (itemCount * 4);
            return(outData);
        }
Exemple #4
0
        UInt32[] ReadDataUnsafeSwapStandalone(MemoryStream data, int itemCount)
        {
            UInt32[] outData = new UInt32[itemCount];

            byte[] bytes = data.GetBuffer();

            unsafe
            {
                fixed(byte *start = bytes)
                {
                    UInt32 *current = (UInt32 *)start;

                    for (int i = 0; i < itemCount; ++i)
                    {
                        outData[i] = BinaryUtilities.SwapUInt32(*current);

                        current++;
                    }
                }
            }
            return(outData);
        }
Exemple #5
0
 public static UInt32 ReadUInt32_safe(this byte[] buff, int offset)
 {
     return(BinaryUtilities.SwapUInt32(Unsafe.As <byte, UInt32>(ref buff[offset])));
 }