@Override
    public void setData(ByteBuffer in) {
        size = in.getInt();
        width = in.getInt();
        height = in.getInt();
        planes = in.getShort();
        bitsPerPixel = in.getShort();
        compression = in.getInt();
        sizeOfBitmap = in.getInt();
        horzResolution = in.getInt();
        vertResolution = in.getInt();
        colorsUsed = in.getInt();
        colorsImportant = in.getInt();

        int cols = (int) colorsUsed;
        if (cols == 0) {
            cols = 1 << bitsPerPixel;
        }

        palette = new PaletteElement[cols];
        for (int i = 0; i < palette.length; i++) {
            PaletteElement el = new PaletteElement();
            el.Blue = in.get();
            el.Green = in.get();
            el.Red = in.get();
            el.Reserved = in.get();
            palette[i] = el;
        }

        // int xorbytes = (((int)height/2) * (int)width * (int)bitsPerPixel) / 8;
        int xorbytes = (((int) height / 2) * (int) width);
        //		System.out.println("POSITION " + in.position() + " : xorbitmap = " + xorbytes + " bytes");

        bitmapXOR = new short[xorbytes];
        for (int i = 0; i < bitmapXOR.length; i++) {
            switch (bitsPerPixel) {
                case 4: {
                    int pix = in.get();
                    bitmapXOR[i] = (short) ((pix >> 4) & 0x0F);
                    i++;
                    bitmapXOR[i] = (short) (pix & 0x0F);
                }
                break;
                case 8: {
                    bitmapXOR[i] = in.get();
                }
                break;
            }
        }


        int height = (int) (this.height / 2);
        int rowsize = (int) width / 8;
        if ((rowsize % 4) > 0) {
            rowsize += 4 - (rowsize % 4);
        }

        //		System.out.println("POSITION " + in.position() + " : andbitmap = " + andbytes + " bytes");

        int andbytes = height * rowsize;   // (((int)height/2) * (int)width) / 8;

        bitmapAND = new short[andbytes];
        for (int i = 0; i < bitmapAND.length; i++) {
            bitmapAND[i] = in.get();
        }
    }