An X-ray imaging apparatus comprises a first grid, a second grid, and an X-ray image detector. The first grid passes X-rays emitted from an X-ray source and produces a first periodic pattern image. The second grid opposes the first grid. The second grid partly blocks the first periodic pattern image and produces a second periodic pattern image with moiré fringes. The X-ray image detector detects the second periodic pattern image and produces image data. The X-ray image detector has pixels arranged in two dimensions in X and Y directions. The M pixels arranged in the Y direction form one group. The group is shifted in the Y direction by the number of the pixels less than M each time. A phase of an intensity modulated signal, composed of pixel values of the pixels in the each shifted group, is calculated. Thereby a differential phase image is produced.