Пример #1
0
        private static BmpInfoHeader ParseBmpInfoHeader(byte[] bmpBytes)
        {
            var size = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0xE);

            if (size != 40)
            {
                var debug = "error";
            }
            var colorsUsed = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x2E);

            if (colorsUsed != 256)
            {
                var debug = "error";
            }

            var imageSize = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x22);

            return(new BmpInfoHeader()
            {
                Size = size,
                Width = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x12),
                Height = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x16),
                Planes = ByteIntConvertion.LoadUInt16FromBytes(bmpBytes, 0x1A),
                BitPerPixel = ByteIntConvertion.LoadUInt16FromBytes(bmpBytes, 0x1C),
                Compression = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x1E),
                ImageSize = imageSize,
                XpixelsPerM = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x26),
                YpixelsPerM = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x2A),
                ColorsUsed = colorsUsed,
                ImportantColors = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x32),
            });
        }
Пример #2
0
        private static BmpHeader ParseHeader(byte[] bmpBytes)
        {
            var valid = bmpBytes[0] == 'B' && bmpBytes[1] == 'M';

            return(new BmpHeader()
            {
                Signature = ByteIntConvertion.LoadUInt16FromBytes(bmpBytes, 0),
                FileSize = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x2),
                Reserved = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0x6),
                DataOffSet = ByteIntConvertion.LoadUInt32FromBytes(bmpBytes, 0xA)
            });
        }
Пример #3
0
        public void UInt16Tests(byte[] input)
        {
            var uInt    = ByteIntConvertion.LoadUInt16FromBytes(input, 0);
            var outData = ByteIntConvertion.LoadBytesFromUInt16(uInt).ToArray();

            Assert.IsTrue(input.Length == outData.Length);

            for (var i = 0; i < input.Length; i++)
            {
                Assert.AreEqual(input[i], outData[i]);
            }
        }