code: public void xor(BitMatrix mask) {
      if (width != mask.getWidth() || height != mask.getHeight()
          || rowSize != mask.getRowSize()) {
        throw new IllegalArgumentException("input matrix dimensions do not match");
      }
      BitArray rowArray = new BitArray(width);
      for (int y = 0; y < height; y++) {
        int offset = y * rowSize;
        int[] row = mask.getRow(y, rowArray).getBitArray();
        for (int x = 0; x < rowSize; x++) {
          bits[offset + x] ^= row[x];
        }
      }
    }
docs: Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the corresponding
  mask bit is set.
  
  @param mask XOR mask