BitMiracle.LibTiff.Classic.Tiff.SwabLong C# (CSharp) Method

SwabLong() public static method

Swaps the bytes in a single 32-bit item.
public static SwabLong ( int &value ) : void
value int The value to swap bytes in.
return void
        public static void SwabLong(ref int value)
        {
            byte[] bytes = new byte[4];
            bytes[0] = (byte)value;
            bytes[1] = (byte)(value >> 8);
            bytes[2] = (byte)(value >> 16);
            bytes[3] = (byte)(value >> 24);

            byte temp = bytes[3];
            bytes[3] = bytes[0];
            bytes[0] = temp;

            temp = bytes[2];
            bytes[2] = bytes[1];
            bytes[1] = temp;

            value = bytes[0] & 0xFF;
            value += (bytes[1] & 0xFF) << 8;
            value += (bytes[2] & 0xFF) << 16;
            value += bytes[3] << 24;
        }
Tiff