public BMPcontainer(File file) throws IOException {

        DataInputStream dataInputStream = new DataInputStream(new FileInputStream(file));


        id[0] = (char) dataInputStream.readByte();
        id[1] = (char) dataInputStream.readByte();

        if ('B' != id[0] && 'M' != id[1]) {
            throw new InvalidFormatException("not BMP file");
        }

        fsize = Integer.reverseBytes(dataInputStream.readInt());
        reservedByApp1 = Short.reverseBytes(dataInputStream.readShort());
        reservedByApp2 = Short.reverseBytes(dataInputStream.readShort());
        offset = Integer.reverseBytes(dataInputStream.readInt());
        // header info
        headerSize = Integer.reverseBytes(dataInputStream.readInt());
        width = Integer.reverseBytes(dataInputStream.readInt());
        height = Integer.reverseBytes(dataInputStream.readInt());
        colorPlane = Short.reverseBytes(dataInputStream.readShort());
        bpp = Short.reverseBytes(dataInputStream.readShort());
        compression = Integer.reverseBytes(dataInputStream.readInt());
        pixelArraySize = Integer.reverseBytes(dataInputStream.readInt());
        ppmWidth = Integer.reverseBytes( dataInputStream.readInt());
        ppmHeight = Integer.reverseBytes(dataInputStream.readInt());
        palette = Integer.reverseBytes(dataInputStream.readInt());
        importantColors = Integer.reverseBytes(dataInputStream.readInt());



        pixelArray = new Color[width][height];

        int i = 0;
        int j = 0;

            for (i = height - 1; i >= 0; i--) {
                for (j = 0; j < width; j++) {
                    int b = dataInputStream.read();
                    int g = dataInputStream.read();
                    int r = dataInputStream.read();

                    pixelArray[j][i] = new Color(r, g, b);

                }
            }

        dataInputStream.close();
    }