Spatially resolved X-ray energy analysis