Expand Minimize

Device.CreateOffscreenPlainSurface(Int32,Int32,Format,Pool) Method (Microsoft.DirectX.Direct3D)

How Do I...?

Creates an off-screen surface.

Definition

Visual BasicPublic Function CreateOffscreenPlainSurface( _
    ByVal width As Integer, _
    ByVal height As Integer, _
    ByVal format As Format, _
    ByVal pool As Pool _
) As Surface
C#public Surface CreateOffscreenPlainSurface(
    int width,
    int height,
    Format format,
    Pool pool
);
C++public:
SurfaceCreateOffscreenPlainSurface(
    int width,
    int height,
    Format format,
    Pool pool
);
JScriptpublic function CreateOffscreenPlainSurface(
    width : int,
    height : int,
    format : Format,
    pool : Pool
) : Surface;

Parameters

width System.Int32
Width of the surface in pixels.
height System.Int32
Height of the surface in pixels.
format Microsoft.DirectX.Direct3D.Format
Format of the surface. For more information, see Format.
pool Microsoft.DirectX.Direct3D.Pool
Surface pool type. For more information, see Pool.

Return Value

Microsoft.DirectX.Direct3D.Surface
The Surface object that is created.

Remarks

The Default pool is appropriate for use with Device.StretchRectangle and Device.ColorFill.

The Managed pool is not allowed when creating an off-screen plain surface. For more information about memory pools, see Pool.

Off-screen plain surfaces are always lockable, regardless of their pool type.

Exceptions
InvalidCallException The method call is invalid. For example, a parameter might contain an invalid value.

How Do I...?

Copy a Texture

This example demonstrates how to copy a texture.

A texture is loaded from a file and duplicated, and all of its AliceBlue color is replaced with transparent black. An area that is ten pixels square from the top right corner of the texture is copied.

In the following C# code example, device is assumed to be the rendering Device, and FlagColorsInverted.bmp is assumed to be in the current directory.


              [C#]
              
using Microsoft.DirectX.Direct3D;
using System.Drawing;

Surface s = null;
				
PaletteEntry[] pal = new PaletteEntry[256];

// Set up the surface for our surface loader.
s = device.CreateOffscreenPlainSurface(32, 32, Format.A8R8G8B8,	Pool.Default);
	
Surface k = TextureLoader.FromFile(device,
                          "FlagColorsInverted.bmp").GetSurfaceLevel(0);

SurfaceLoader.FromSurface(s, out pal, new Rectangle(0,0,9,9), k, out pal,
               new Rectangle(0,0,9,9), Filter.Box, Color.AliceBlue.ToArgb());
Show:
© 2014 Microsoft