Esempio n. 1
0
        /// <summary>
        /// Load data from file with the provided bitdepth and byte order.
        /// </summary>
        public RawFile(string fileName, int bitDepth, BYTE_ORDER byteOrder = BYTE_ORDER.WINDOWS, int stripSize = STRIP_SIZE)
        {
            if (stripSize % 4 != 0)
            {
                stripSize += stripSize % 4;
            }

            FileName  = fileName;
            BitDepth  = bitDepth;
            ByteOrder = byteOrder;
            StripSize = stripSize;

            FindSize();
        }
Esempio n. 2
0
        /// <summary>
        /// Loads 16 bit file and convert to float.
        /// </summary>
        public static float[] Load16Bit(string fileName, BYTE_ORDER byteOrder)
        {
            byte[] bytes = File.ReadAllBytes(fileName);

            int size = bytes.Length / 2;

            float[] data      = new float[size];
            bool    bigendian = byteOrder == BYTE_ORDER.MAC;

            for (int x = 0, i = 0; x < size; x++)
            {
                data[x]  = (bigendian) ? (bytes[i++] * 256.0f + bytes[i++]) : (bytes[i++] + bytes[i++] * 256.0f);
                data[x] /= (float)ushort.MaxValue;
            }

            return(data);
        }