Sdílet prostřednictvím


SurfaceFormat Enumeration

Defines various types of surface formats.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Syntax

public enum SurfaceFormat

Members

  Member name Description
Alpha8 (Unsigned format) 8-bit alpha only.
Bgr233 (Unsigned format) 8-bit BGR texture format using 2 bits for blue, 3 bits for green, and 3 bits for red.
Bgr24 (Unsigned format) 24-bit BGR pixel format with 8 bits per channel.
Bgr32 (Unsigned format) 32-bit BGR pixel format, where 8 bits are reserved for each color.
Bgr444 (Unsigned format) 16-bit BGR pixel format using 4 bits for each color.
Bgr555 (Unsigned format) 16-bit BGR pixel format where 5 bits are reserved for each color.
Bgr565 (Unsigned format) 16-bit BGR pixel format with 5 bits for blue, 6 bits for green, and 5 bits for red.
Bgra1010102 (Unsigned format) 32-bit pixel format using 10 bits each for blue, green, and red, and 2 bits for alpha.
Bgra2338 (Unsigned format) 16-bit BGRA format using 2 bits for blue, 3 bits each for red and green, and 8 bits for alpha.
Bgra4444 (Unsigned format) 16-bit BGRA pixel format with 4 bits for each channel.
Bgra5551 (Unsigned format) 16-bit BGRA pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
Color (Unsigned format) 32-bit ARGB pixel format with alpha, using 8 bits per channel.
Depth15Stencil1 (Buffer format) 16-bit depth-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel.
Depth16 (Buffer format) 16-bit depth-buffer bit depth.
Depth24 (Buffer format) 32-bit depth-buffer bit depth using 24 bits for the depth channel.
Depth24Stencil4 (Buffer format) 32-bit depth-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel.
Depth24Stencil8 (Buffer format) 32-bit depth-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel.
Depth24Stencil8Single (Buffer format) A non-lockable format that contains 24 bits of depth (in a 24-bit floating-point format − 20e4) and 8 bits of stencil.
Depth32 (Buffer format) 32-bit depth-buffer bit depth.
Dxt1 DXT1 compression texture format. The runtime will not allow an application to create a surface using a DXTn format unless the surface dimensions are multiples of 4. This applies to offscreen-plain surfaces, render targets, 2D textures, cube textures, and volume textures.
Dxt2 DXT2 compression texture format. The runtime will not allow an application to create a surface using a DXTn format unless the surface dimensions are multiples of 4. This applies to offscreen-plain surfaces, render targets, 2D textures, cube textures, and volume textures.
Dxt3 DXT3 compression texture format. The runtime will not allow an application to create a surface using a DXTn format unless the surface dimensions are multiples of 4. This applies to offscreen-plain surfaces, render targets, 2D textures, cube textures, and volume textures.
Dxt4 DXT4 compression texture format. The runtime will not allow an application to create a surface using a DXTn format unless the surface dimensions are multiples of 4. This applies to offscreen-plain surfaces, render targets, 2D textures, cube textures, and volume textures.
Dxt5 DXT5 compression texture format. The runtime will not allow an application to create a surface using a DXTn format unless the surface dimensions are multiples of 4. This applies to offscreen-plain surfaces, render targets, 2D textures, cube textures, and volume textures.
HalfSingle (Floating-point format) 16-bit float format using 16 bits for the red channel.
HalfVector2 (Floating-point format) 32-bit float format using 16 bits for the red channel and 16 bits for the green channel.
HalfVector4 (Floating-point format) 64-bit float format using 16 bits for each channel (alpha, blue, green, red).
Luminance16 (Unsigned format) 16-bit luminance only.
Luminance8 (Unsigned format) 8-bit luminance only.
LuminanceAlpha16 (Unsigned format) 16-bit using 8 bits each for alpha and luminance.
LuminanceAlpha8 (Unsigned format) 8-bit using 4 bits each for alpha and luminance.
Multi2Bgra32 MultiElement texture (not compressed)
NormalizedAlpha1010102 (Mixed format) 32-bit bump-map format using 2 bits for alpha and 10 bits each for w, v, and u.
NormalizedByte2 (Signed format) 16-bit bump-map format using 8 bits each for u and v data.
NormalizedByte2Computed (Signed format) 16-bit normal compression format. The texture sampler computes the C channel from: C = sqrt(1 − U2 − V2).
NormalizedByte4 (Signed format) 32-bit bump-map format using 8 bits for each channel.
NormalizedLuminance16 (Mixed format) 16-bit bump-map format with luminance using 6 bits for luminance, and 5 bits each for v and u.
NormalizedLuminance32 (Mixed format) 32-bit bump-map format with luminance using 8 bits for each channel.
NormalizedShort2 (Signed format) 32-bit bump-map format using 16 bits for each channel.
NormalizedShort4 (Signed format) 64-bit bump-map format using 16 bits for each component.
Palette8 (Unsigned format) 8-bit color indexed.
PaletteAlpha16 (Unsigned format) 8-bit color indexed with 8 bits of alpha.
Rg32 (Unsigned format) 32-bit pixel format using 16 bits each for red and green.
Rgb32 (Unsigned format) 32-bit RGB pixel format, where 8 bits are reserved for each color.
Rgba1010102 (Unsigned format) 32-bit RGBA pixel format using 10 bits for each color and 2 bits for alpha.
Rgba32 (Unsigned format) 32-bit RGBA pixel format with alpha, using 8 bits per channel.
Rgba64 (Unsigned format) 64-bit RGBA pixel format using 16 bits for each component.
Single (IEEE format) 32-bit float format using 32 bits for the red channel.
Unknown Surface format is unknown.
Vector2 (IEEE format) 64-bit float format using 32 bits for the red channel and 32 bits for the green channel.
Vector4 (IEEE format) 128-bit float format using 32 bits for each channel (alpha, blue, green, red).
VideoGrGb A 16-bit packed RGB format analogous to VideoYuYv (U0Y0, V0Y1, U2Y2, and so on). It requires a pixel pair to properly represent the color value. The first pixel in the pair contains 8 bits of green (in the low 8 bits) and 8 bits of red (in the high 8 bits). The second pixel contains 8 bits of green (in the low 8 bits) and 8 bits of blue (in the high 8 bits). Together, the two pixels share the red and blue components, while each has a unique green component (R0G0, B0G1, R2G2, and so on). The texture sampler does not normalize the colors when looking up into a pixel shader; they remain in the range of 0.0f to 255.0f. This is true for all programmable pixel shader models. For the fixed-function pixel shader, the hardware should normalize to the 0.f to 1.f range and essentially treat it as the VideoUyVy texture. Hardware that exposes this format must have PixelShader1xMaxValue set to a value capable of handling that range.
VideoRgBg A 16-bit packed RGB format analogous to VideoUyVy (Y0U0, Y1V0, Y2U2, and so on). It requires a pixel pair to properly represent the color value. The first pixel in the pair contains 8 bits of green (in the high 8 bits) and 8 bits of red (in the low 8 bits). The second pixel contains 8 bits of green (in the high 8 bits) and 8 bits of blue (in the low 8 bits). Together, the two pixels share the red and blue components, while each has a unique green component (G0R0, G1B0, G2R2, and so on). The texture sampler does not normalize the colors when looking up into a pixel shader; they remain in the range of 0.0f to 255.0f. This is true for all programmable pixel shader models. For the fixed-function pixel shader, the hardware should normalize to the 0.f to 1.f range and essentially treat it as the VideoUyVy texture. Hardware that exposes this format must have PixelShader1xMaxValue set to a value capable of handling that range.
VideoUyVy YUY2 format (PC98 compliance)
VideoYuYv VideoYuYv format (PC98 compliance)

Remarks

In the XNA Framework, all two-dimensional (2D) images are represented by a range of memory called a surface. Within a surface, each element holds a color value representing a small section of the image, called a pixel. An image's detail level is defined by both the number of pixels needed to represent the image, and the number of bits needed for the image's color spectrum. For example, an image that is 800 pixels wide by 600 pixels high with 32 bits of color for each pixel (written as 800×600×32) is more detailed than an image that is 640 pixels wide by 480 pixels tall with 16 bits of color for each pixel (written as 640×480×16). Likewise, the more detailed image requires a larger surface to store the data. For an 800×600×32 image, the surface's array dimensions are 800×600, and each element holds a 32-bit value to represent its color.

All formats are listed from left to right, most-significant bit to least-significant bit. For example, ARGB formats are ordered from the most-significant bit channel A (alpha), to the least-significant bit channel B (blue). When traversing surface data, the data is stored in memory from least-significant bit to most-significant bit, which means that the channel order in memory is from least-significant bit (blue) to most-significant bit (alpha).

The default value for formats that contain undefined channels (Rg32, Alpha8, and so on) is 1. The only exception is the Alpha8 format, which is initialized to 000 for the three color channels.

The order of the bits is from the most-significant byte first, so LuminanceAlpha16 indicates that the high byte of this 2-byte format is alpha. Depth16 indicates a 16-bit integer value and an application-lockable surface.

Floating-point formats are also known as s10e5 formats. IEEE formats are also known as s23e8 formats. Data in mixed formats can contain a combination of unsigned data and signed data. Data in a signed format can be both positive and negative. Signed formats use combinations of (U), (V), (W), and (Q) data. Data in an unsigned format must be positive. Unsigned formats use combinations of (R)ed, (G)reen, (B)lue, (A)lpha, (L)uminance, and (P)alette data. Palette data is also referred to as color indexed data because the data is used to index a color palette.

Back-Buffer or Display Formats

The following formats are the only valid formats for a back buffer or a display.

Format Back Buffer Display
Bgra1010102 × × (full-screen mode only)
Color ×
Bgr32 × ×
Bgra5551 ×
Bgr555 × ×
Bgr565 × ×

Depth-stencil Buffer Formats

Depth-stencil buffers each have unique formats. All depth-stencil formats except Depth16Lockable indicate no particular bit ordering per pixel, and the driver is allowed to consume more than the indicated number of bits-per-depth channel (but not stencil channel).

Warning

Depth stencil surfaces must be created with ResourceManagementMode.Manual, and recreated when the device is reset.

DXT Compressed Texture Formats

The runtime will not allow an application to create a surface using a DXTn format unless the surface dimensions are multiples of 4. This applies to offscreen-plain surfaces, render targets, 2D textures, cube textures, and volume textures.

Direct3D Equivalents

A mapping of each Direct3D 9 surface format name to the SurfaceFormat equivalent is listed in the following table.

Direct3D Surface Format SurfaceFormat equivalent
Floating Point
Float32D3DFMT_R32FSingle
D3DFMT_G32R32FVector2
D3DFMT_A32B32G32R32FVector4
Float16D3DFMT_R16FHalfSingle
D3DFMT_G16R16FHalfVector2
D3DFMT_A16B16G16R16FHalfVector4
Unsigned Normalized
64 bppD3DFMT_A16B16G16R16Rgba64
32 bppD3DFMT_A8R8G8B8Color
D3DFMT_X8R8G8B8Bgr32
D3DFMT_A8B8G8R8Rgba32
D3DFMT_X8B8G8R8Rgb32
D3DFMT_A2R10G10B10Bgra1010102
D3DFMT_A2B10G10R10Rgba1010102
D3DFMT_G16R16Rg32
24 bppD3DFMT_R8G8B8Bgr24
16 bppD3DFMT_R5G6B5Bgr565
D3DFMT_A1R5G5B5Bgra5551
D3DFMT_X1R5G5B5Bgr555
D3DFMT_A4R4G4B4Bgra4444
D3DFMT_X4R4G4B4Bgr444
D3DFMT_A8R3G3B2Bgra2338
8 bppD3DFMT_A8Alpha8
D3DFMT_R3G3B2Bgr233
Signed Normalized
D3DFMT_V8U8NormalizedByte2
D3DFMT_Q8W8V8U8NormalizedByte4
D3DFMT_V16U16NormalizedShort2
D3DFMT_Q16W16V16U16NormalizedShort4
D3DFMT_CxV8U8NormalizedByte2Computed
Block Compressed
D3DFMT_Dxt1Dxt1
D3DFMT_Dxt2Dxt2
D3DFMT_Dxt3Dxt3
D3DFMT_Dxt4Dxt4
D3DFMT_Dxt5Dxt5
Luminance
D3DFMT_L8Luminance8
D3DFMT_L16Luminance16
D3DFMT_A4L4LuminanceAlpha8
D3DFMT_A8L8LuminanceAlpha16
Palettized
D3DFMT_P8Palette8
D3DFMT_A8P8PaletteAlpha16
Mixed Formats
D3DFMT_A2W10V10U10NormalizedAlpha1010102
D3DFMT_X8L8V8U8NormalizedLuminance32
D3DFMT_L6V5U5NormalizedLuminance16
D3DFMT_Yuy2VideoUyVy
D3DFMT_UyvyVideoYuYv
D3DFMT_Multi2Argb8Multi2Bgra32
D3DFMT_R8G8B8G8VideoGrGb
D3DFMT_G8R8G8B8VideoRgBg
Depth Formats
D3DFMT_D15S1Depth15Stencil1
D3DFMT_D16Depth16
D3DFMT_D24S8Depth24Stencil8
D3DFMT_D24SingleS8Depth24Stencil8Single
D3DFMT_D24X4S4Depth24Stencil4
D3DFMT_D24X8Depth24
D3DFMT_D32Depth32

See Also

Concepts

Xbox 360 Surface Formats

Reference

DisplayMode.Format Property
DisplayModeCollection.Item Property
GraphicsAdapter.CheckDepthStencilMatch Method
GraphicsAdapter.CheckDeviceFormat Method
GraphicsAdapter.CheckDeviceFormatConversion Method
GraphicsAdapter.CheckDeviceMultiSampleType Method
GraphicsAdapter.CheckDeviceType Method
PresentationParameters.BackBufferFormat Property
Texture2D Constructor
Texture2D.Format Property
Texture3D Constructor
Texture3D.Format Property
TextureCreationParameters Constructor
TextureCreationParameters.Format Property
TextureCube Constructor
TextureCube.Format Property
TextureInformation Constructor
TextureInformation.Format Property
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista