Shadow map to bitmap

I’ve been working with shadow maps on a terrain program, and have the basics working fine. I’m basically following the method at but rendering shadow map in a PBuffer.

However I would like to take the generated shadow map texture and ‘project’ it ‘back’ so I can save it into an image file. That is I want to end up with an image that is a straightforward undistorted map of the terrain showing where the shadows are.

The application isn’t realtime, so speed is not crucial. What is the easiest method of doing this?