Flat-field correction methods are implemented in order to eliminate non-uniformities in X-ray imaging sensors. If the compensation is perfect, then the remaining variations result from noise over the detector area. The efficiency of the compensation is reduced when an object is placed in the beam. A principle cause of this effect is believed to be the spectrum hardening caused by the object. In a normal application the correction factors are calculated for a certain spectrum, meaning that the average of the correction for the individual photon energies are used. If the composition of the spectrum changes the correction factor will also change. In this paper, we present a theory for the sensitivity of the gain constants on X-ray spectra. The theory is supported by experimental data obtained with X-ray spectra and monochromatic X-rays