Beispiel #1
0
        public static S24 ReadS24(byte[] buffer, uint start)
        {
            S24 result = new S24();

            result._value = (buffer[start] | (buffer[start + 1] << 8) | (buffer[start + 2] << 16));

            SetS24Sign(ref result);

            return(result);
        }
Beispiel #2
0
        public static S24 ReadS24(BinaryReader reader)
        {
            S24 result = new S24();

            result._value = ((reader.ReadByte()) | (reader.ReadByte() << 8) | (reader.ReadByte() << 16));

            SetS24Sign(ref result);

            return(result);
        }
Beispiel #3
0
        private static void SetS24Sign(ref S24 result)
        {
            if (0 != (0x800000 & result._value))
            {
                // Is there maybe a better way to do this?
                uint buf = (uint)result._value;
                buf |= 0xff000000;

                result._value = (int)buf;

                /*if (result._value < 0)
                 * {
                 *  result._value++;
                 * }*/
            }
        }
Beispiel #4
0
 public static void WriteS24(BinaryWriter writer, S24 value)
 {
     WriteS24(writer, (int)value);
 }