The invention relates to an x-ray device for providing x-rays. The x-ray device 20 comprises an x-ray source 2 for generating x-rays and a grating device for absorbing at least a part of the x-rays, wherein the grating device 3 has lamellae comprising an x-ray absorbing material. At least one of the x-ray source 2 and the grating device 3 is adapted for modifying an angular orientation of the x-rays relative to the lamellae. By modifying the angular orientation of the x-rays relative to the lamellae, the ways, along which the x-rays traverse the lamellae, are modified, i.e. the absorption of the x-rays by the lamellae is modified. This modified absorption leads to a modified energy distribution of the x-rays such that by modifying the angular orientation of the x-rays relative to the lamellae different energy spectra of the x-rays can be realized in a technically relatively simple way.