The hyperspectral X-ray imaging has been long sought in various fields from material analysis to medical diagnosis. Here we propose a new semiconductor detector structure to realize energy-resolved imaging at potentially low cost. The working principle is based on the strong energy-dependent absorption of X-ray in solids. Namely, depending on the energy, X-ray photons experience dramatically different attenuation. An array or matrix of semiconductor cells is to map the X-ray intensity along its trajectory. The X-ray spectrum could be extracted from a Laplace like transform or even a supervised machine learning. We demonstrated an energy-resolved X-ray detection with a regular silicon camera.