What do I need to do to save an image my program has generated (possibly from the camera, possibly not) to the system photo library on the iPhone?

What do I need to do to save an image my program has generated (possibly from the camera, possibly not) to the system photo library on the iPhone?