A tiny amount of ionising radiation is passed through the body. In the past, this went onto a sheet of special film. Nowadays x-ray examinations are more likely to use a device that will capture transmitted x-rays to create an electronic image.
The calcium in bones blocks the passage of radiation, so healthy bones show up as white or grey. On the other hand, radiation passes easily through air spaces, so healthy lungs appear black.