Application.CaptureScreenshot vs ReadPixels EncodeToPNG

Is Application.CaptureScreenshot the same as

`
// snippet from WWWForm

var tex = new Texture2D( width, height, TextureFormat.RGB24, false );

// Read screen contents into the texture
tex.ReadPixels( Rect(0, 0, width, height), 0, 0 );
tex.Apply();

// Encode texture into PNG
var bytes = tex.EncodeToPNG();
Destroy( tex );

`

http://unity3d.com/support/documentation/ScriptReference/Application.CaptureScreenshot.html
vs
http://unity3d.com/support/documentation/ScriptReference/WWWForm.html

Essentially yes, but the ReadPixels/EncodePNG variant is much slower (by several factors, IIRC), and the first 2-3 frames that are captured are either lost or contain garbage (when capturing continuously from the start).

My guess is, Application.CaptureScreenshot was included in some later version of Unity. Since we discovered it, we use that, and it works like a charm.

Note if you are going to capture a sequence of images, you’ll find Time.captureFramerate very useful, it ensures that everything (physics, animations, Update-transformations, …) happens at a defined framerate independently from how long it really takes to render a single frame (or to capture and save it to disk).

The ReadPixels approach might have the slight advantage that it’s possible to only capture a portion of the screen, but it’s still better to use the CaptureScreenshot and then use some batch tool to crop your images afterwards, if that’s what you need. Also, CaptureScreenshot can create high-resolution snapshots, much higher than your screen resolution.