The optical and near-infrared distribution of light in the edge-on galaxy IC 2531