Share via


SurfaceLoader.Save(String,ImageFileFormat,Surface,PaletteEntry) Method (Microsoft.DirectX.Direct3D)

How Do I...?

  • Save a Screenshot

Saves a surface to a file.

Definition

Visual Basic Public Shared Sub Save( _
    ByVal destFile As String, _
    ByVal destFormat As ImageFileFormat, _
    ByVal srcSurface As Surface, _
    ByRef sourcePalette As PaletteEntry _
)
C# public static void Save(
    string destFile,
    ImageFileFormat destFormat,
    Surface srcSurface,
    out PaletteEntry sourcePalette
);
C++ public:
static void Save(
    StringLeave SitedestFile,
    ImageFileFormat destFormat,
    SurfacesrcSurface,
    [Out] PaletteEntrysourcePalette
);
JScript public static function Save(
    destFile : String,
    destFormat : ImageFileFormat,
    srcSurface : Surface,
    sourcePalette : PaletteEntry
);

Parameters

destFile System.String
String that contains the destination file name.
destFormat Microsoft.DirectX.Direct3D.ImageFileFormat
An ImageFileFormat object that specifies the file format to use when saving the surface to a file. This method supports saving to all ImageFileFormat types except Portable Pixmap (.ppm) and Targa/Truevision Graphics Adapter (.tga).
srcSurface Microsoft.DirectX.Direct3D.Surface
A Surface object that represents the source surface to save to a file.
sourcePalette Microsoft.DirectX.Direct3D.PaletteEntry[]
A PaletteEntry array that contains the source palette entries.

Remarks

This method handles conversion to and from compressed texture formats.

Exceptions

InvalidCallException

The method call is invalid. For example, a method's parameter might contain an invalid value.

How Do I...?

Save a Screenshot

This example demonstrates how to save a screen shot to a file.

The back buffer is retrieved and saved as a bitmap image.

In the following C# code example, device is assumed to be the rendering Device. This code is called after rendering is complete.

              [C#]
              
using Microsoft.DirectX.Direct3D;

Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
SurfaceLoader.Save("Screenshot.bmp", ImageFileFormat.Bmp, backbuffer);
backbuffer.Dispose();