I haven't developed on iOS but I remember reading someplace that when an app is loading it can display an image of what it looked like when the user most recently left it, in order to give the appearance of loading more quickly. I think it was one of Marco Arment's blog posts, but his site isn't available right now.
Anyway I also don't have an iPhone 4, but FaceTime for OS X shows the camera view whenever it's on so that you can see yourself whenever starting a call. I imagine FaceTime for iOS does something similar.
If you combine those two things, you get one possible explanation for what's going on. One that's pretty benign, but should probably still be avoided because it obviously spooks users. Oh, and it should probably be at the API level so that the last thing an app saves is never camera data.
That's not what's going on here. Some of the pictures that it's been showing me have come from times that I definitely wasn't using facetime (one was from while I was driving, even). Something is triggering it to take a picture, but it's not facetime.
I've got a cheap Samsung phone that takes phantom photos too. Why I'm not worried?
A: It's front-facing, so it's never of me.
B: The phone is completely worthless, so it never takes decent photos anyways. (Generally of my pocket.)
The only reason people are spooked is that Apple has higher expectations (also, tribal instinct). My buddy's Nexus phone module will crash constantly, requiring a reboot before use of the camera. His response: "Eh, whatever."
The built-in Mail app does this (stored screenshot of current app state), but 3rd-party apps do not have this ability.
3rd-party apps can display a single static image (default.png) on boot. It is common for this image to be a screenshot of the UI without any content (e.g. nav bar, toolbars, but no buttons or data) in order to give the impression of a faster/more-progressive loading process.
I don't know how it is implemented under the hood, but Facetime on iOS does not appear to be a separate app (from the user perspective, at least). Someone who has jailbroken their phone and inspected the filesystem may be able to speak to this point more directly.
Fast app switching, depending on memory availability, does sometimes freeze an app and save state to stable storage. It's possible that this is a source of the rogue image data. A quick test with Instagram suggests that the camera is disabled when an app is "backgrounded." Perhaps Apple's built-in apps (e.g. Phone, Facetime) behave differently.
Apps created outside of Apple and in the App Store have no way to change what graphic is shown when the app is launching. You can display a static image (Default.png), but that cannot be dynamically modified later.
This is irrelevant. The bug happens specifically while using Facetime, an Apple app, so it might be feasible for it to set the last image as the launch image. Also, Apple is notorious for using undocumented APIs in their own apps.
It would be nice if someone could look into the iPhone's exact behavior in this regard. The FaceTime app on the new iPad doesn't seem to save an actual camera image with the screenshot on quitting. The UI comes up but the whole screen is just dark for a split second before it displays the live camera image. This is true whether you quit the app explicitly or just quickly close it and come back.
This does happen: iOS writes a snapshot of the screen when an app moves to the background. You can notice that when you open an app that you ran recently and a stale, slightly artifacted screen appears briefly before updating. That's the snapshot.
But this is at the OS level, an app has no control over it, and it's irrelevant for the whole camera thing.