Bound states of a two-dimensional electron gas in inhomogeneous magnetic fields