private BmpHeaderInfo readBmpHeaderInfo(final InputStream is, final FormatCompliance formatCompliance) throws ImagingException, IOException {
        final byte identifier1 = readByte("Identifier1", is, "Not a Valid BMP File");
        final byte identifier2 = readByte("Identifier2", is, "Not a Valid BMP File");

        if (formatCompliance != null) {
            formatCompliance.compareBytes("Signature", BMP_HEADER_SIGNATURE, new byte[] { identifier1, identifier2 });
        }

        final int fileSize = read4Bytes("File Size", is, "Not a Valid BMP File", getByteOrder());
        final int reserved = read4Bytes("Reserved", is, "Not a Valid BMP File", getByteOrder());
        final int bitmapDataOffset = read4Bytes("Bitmap Data Offset", is, "Not a Valid BMP File", getByteOrder());

        final int bitmapHeaderSize = read4Bytes("Bitmap Header Size", is, "Not a Valid BMP File", getByteOrder());
        int width = 0;
        int height = 0;
        int planes = 0;
        int bitsPerPixel = 0;
        int compression = 0;
        int bitmapDataSize = 0;
        int hResolution = 0;
        int vResolution = 0;
        int colorsUsed = 0;
        int colorsImportant = 0;
        int redMask = 0;
        int greenMask = 0;
        int blueMask = 0;
        int alphaMask = 0;
        int colorSpaceType = 0;
        final BmpHeaderInfo.ColorSpace colorSpace = new BmpHeaderInfo.ColorSpace();
        colorSpace.red = new BmpHeaderInfo.ColorSpaceCoordinate();
        colorSpace.green = new BmpHeaderInfo.ColorSpaceCoordinate();
        colorSpace.blue = new BmpHeaderInfo.ColorSpaceCoordinate();
        int gammaRed = 0;
        int gammaGreen = 0;
        int gammaBlue = 0;
        int intent = 0;
        int profileData = 0;
        int profileSize = 0;
        int reservedV5 = 0;

        if (bitmapHeaderSize < 40) {
            throw new ImagingException("Invalid/unsupported BMP file");
        }
        // BITMAPINFOHEADER
        width = read4Bytes("Width", is, "Not a Valid BMP File", getByteOrder());
        height = read4Bytes("Height", is, "Not a Valid BMP File", getByteOrder());
        planes = read2Bytes("Planes", is, "Not a Valid BMP File", getByteOrder());
        bitsPerPixel = read2Bytes("Bits Per Pixel", is, "Not a Valid BMP File", getByteOrder());
        compression = read4Bytes("Compression", is, "Not a Valid BMP File", getByteOrder());
        bitmapDataSize = read4Bytes("Bitmap Data Size", is, "Not a Valid BMP File", getByteOrder());
        hResolution = read4Bytes("HResolution", is, "Not a Valid BMP File", getByteOrder());
        vResolution = read4Bytes("VResolution", is, "Not a Valid BMP File", getByteOrder());
        colorsUsed = read4Bytes("ColorsUsed", is, "Not a Valid BMP File", getByteOrder());
        colorsImportant = read4Bytes("ColorsImportant", is, "Not a Valid BMP File", getByteOrder());
        if (bitmapHeaderSize >= 52 || compression == BI_BITFIELDS) {
            // 52 = BITMAPV2INFOHEADER, now undocumented
            // see https://en.wikipedia.org/wiki/BMP_file_format
            redMask = read4Bytes("RedMask", is, "Not a Valid BMP File", getByteOrder());
            greenMask = read4Bytes("GreenMask", is, "Not a Valid BMP File", getByteOrder());
            blueMask = read4Bytes("BlueMask", is, "Not a Valid BMP File", getByteOrder());
        }
        if (bitmapHeaderSize >= 56) {
            // 56 = the now undocumented BITMAPV3HEADER sometimes used by
            // Photoshop
            // see [BROKEN URL] http://forums.adobe.com/thread/751592?tstart=1
            alphaMask = read4Bytes("AlphaMask", is, "Not a Valid BMP File", getByteOrder());
        }
        if (bitmapHeaderSize >= 108) {
            // BITMAPV4HEADER
            colorSpaceType = read4Bytes("ColorSpaceType", is, "Not a Valid BMP File", getByteOrder());
            colorSpace.red.x = read4Bytes("ColorSpaceRedX", is, "Not a Valid BMP File", getByteOrder());
            colorSpace.red.y = read4Bytes("ColorSpaceRedY", is, "Not a Valid BMP File", getByteOrder());
            colorSpace.red.z = read4Bytes("ColorSpaceRedZ", is, "Not a Valid BMP File", getByteOrder());
            colorSpace.green.x = read4Bytes("ColorSpaceGreenX", is, "Not a Valid BMP File", getByteOrder());
            colorSpace.green.y = read4Bytes("ColorSpaceGreenY", is, "Not a Valid BMP File", getByteOrder());
            colorSpace.green.z = read4Bytes("ColorSpaceGreenZ", is, "Not a Valid BMP File", getByteOrder());
            colorSpace.blue.x = read4Bytes("ColorSpaceBlueX", is, "Not a Valid BMP File", getByteOrder());
            colorSpace.blue.y = read4Bytes("ColorSpaceBlueY", is, "Not a Valid BMP File", getByteOrder());
            colorSpace.blue.z = read4Bytes("ColorSpaceBlueZ", is, "Not a Valid BMP File", getByteOrder());
            gammaRed = read4Bytes("GammaRed", is, "Not a Valid BMP File", getByteOrder());
            gammaGreen = read4Bytes("GammaGreen", is, "Not a Valid BMP File", getByteOrder());
            gammaBlue = read4Bytes("GammaBlue", is, "Not a Valid BMP File", getByteOrder());
        }
        if (bitmapHeaderSize >= 124) {
            // BITMAPV5HEADER
            intent = read4Bytes("Intent", is, "Not a Valid BMP File", getByteOrder());
            profileData = read4Bytes("ProfileData", is, "Not a Valid BMP File", getByteOrder());
            profileSize = read4Bytes("ProfileSize", is, "Not a Valid BMP File", getByteOrder());
            reservedV5 = read4Bytes("Reserved", is, "Not a Valid BMP File", getByteOrder());
        }

        if (LOGGER.isLoggable(Level.FINE)) {
            debugNumber("identifier1", identifier1, 1);
            debugNumber("identifier2", identifier2, 1);
            debugNumber("fileSize", fileSize, 4);
            debugNumber("reserved", reserved, 4);
            debugNumber("bitmapDataOffset", bitmapDataOffset, 4);
            debugNumber("bitmapHeaderSize", bitmapHeaderSize, 4);
            debugNumber("width", width, 4);
            debugNumber("height", height, 4);
            debugNumber("planes", planes, 2);
            debugNumber("bitsPerPixel", bitsPerPixel, 2);
            debugNumber("compression", compression, 4);
            debugNumber("bitmapDataSize", bitmapDataSize, 4);
            debugNumber("hResolution", hResolution, 4);
            debugNumber("vResolution", vResolution, 4);
            debugNumber("colorsUsed", colorsUsed, 4);
            debugNumber("colorsImportant", colorsImportant, 4);
            if (bitmapHeaderSize >= 52 || compression == BI_BITFIELDS) {
                debugNumber("redMask", redMask, 4);
                debugNumber("greenMask", greenMask, 4);
                debugNumber("blueMask", blueMask, 4);
            }
            if (bitmapHeaderSize >= 56) {
                debugNumber("alphaMask", alphaMask, 4);
            }
            if (bitmapHeaderSize >= 108) {
                debugNumber("colorSpaceType", colorSpaceType, 4);
                debugNumber("colorSpace.red.x", colorSpace.red.x, 1);
                debugNumber("colorSpace.red.y", colorSpace.red.y, 1);
                debugNumber("colorSpace.red.z", colorSpace.red.z, 1);
                debugNumber("colorSpace.green.x", colorSpace.green.x, 1);
                debugNumber("colorSpace.green.y", colorSpace.green.y, 1);
                debugNumber("colorSpace.green.z", colorSpace.green.z, 1);
                debugNumber("colorSpace.blue.x", colorSpace.blue.x, 1);
                debugNumber("colorSpace.blue.y", colorSpace.blue.y, 1);
                debugNumber("colorSpace.blue.z", colorSpace.blue.z, 1);
                debugNumber("gammaRed", gammaRed, 4);
                debugNumber("gammaGreen", gammaGreen, 4);
                debugNumber("gammaBlue", gammaBlue, 4);
            }
            if (bitmapHeaderSize >= 124) {
                debugNumber("intent", intent, 4);
                debugNumber("profileData", profileData, 4);
                debugNumber("profileSize", profileSize, 4);
                debugNumber("reservedV5", reservedV5, 4);
            }
        }

        return new BmpHeaderInfo(identifier1, identifier2, fileSize, reserved, bitmapDataOffset, bitmapHeaderSize, width, height, planes, bitsPerPixel,
                compression, bitmapDataSize, hResolution, vResolution, colorsUsed, colorsImportant, redMask, greenMask, blueMask, alphaMask, colorSpaceType,
                colorSpace, gammaRed, gammaGreen, gammaBlue, intent, profileData, profileSize, reservedV5);
    }
Constructs a new instance with the little-endian byte order.
src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java