Disclosed herein is an apparatus for detecting X-ray. The apparatus has an X-ray absorption layer with an electrode, one or more voltage comparators configured to compare a voltage of the electrode to one or more thresholds, a counter configured to register the number of X-ray photons absorbed by the X-ray absorption layer, and a controller.