Texture2D Class Reference

Class representing a 2D texture. More...

Inheritance diagram for Texture2D:
Texture PixelBuffer

List of all members.

Public Member Functions

 Texture2D (int width, int height, bool mipmap, PixelFormat format)
 Creates a 2D texture.
 Texture2D (int width, int height, bool mipmap, PixelFormat format, PixelBufferOption option)
 Creates a 2D texture (with options)
 Texture2D (string fileName, bool mipmap)
 Creates a 2D texture (from a file)
 Texture2D (string fileName, bool mipmap, PixelFormat format)
 Creates a 2D texture (from a file, with format conversion)
 Texture2D (byte[] fileImage, bool mipmap)
 Creates a 2D texture (from a file image)
 Texture2D (byte[] fileImage, bool mipmap, PixelFormat format)
 Creates a 2D texture (from a file image, with format conversion)
override Object ShallowClone ()
 Creates a copy of a 2D texture.
void SetPixels (int level, Array pixels)
 Sets pixel data.
void SetPixels (int level, Array pixels, int dx, int dy, int dw, int dh)
 Sets pixel data (with range)
void SetPixels (int level, Array pixels, int offset, int pitch)
 Sets pixel data (with byte offset)
void SetPixels (int level, Array pixels, PixelFormat format)
 Sets pixel data (with format conversion)
void SetPixels (int level, Array pixels, PixelFormat format, int offset, int pitch, int dx, int dy, int dw, int dh)
 Sets pixel data (with format conversion, with byte offset, with range)
void GenerateMipmap ()
 Automatically creates a mipmap image.

Protected Member Functions

 Texture2D (Texture2D texture)
 Creates a copy of a 2D texture.

Detailed Description

Class representing a 2D texture.


Constructor & Destructor Documentation

Texture2D ( int  width,
int  height,
bool  mipmap,
PixelFormat  format 
)

Creates a 2D texture.

Parameters:
widthTexture width
heightTexture height
mipmapExistence/Lack of mipmap
formatPixel format

Creates the 2D texture using the specified parameters. Rgba, Rgba4444, Rgba5551, Rgb565, LuminanceAlpha, Luminance, Alpha, RgbaH, LuminanceAlphaH, LuminanceH, AlphaH, Dxt1, Dxt2, Dxt3, Dxt4, or Dxt5 can be specified to the pixel format.

When the pixel format is DXT, the width and height must be a power of 2.

Texture2D ( int  width,
int  height,
bool  mipmap,
PixelFormat  format,
PixelBufferOption  option 
)

Creates a 2D texture (with options)

Parameters:
widthTexture width
heightTexture height
mipmapExistence/Lack of mipmap
formatPixel format
optionPixel buffer creation option

Creates the 2D texture using the specified parameters. Rgba, Rgba4444, Rgba5551, Rgb565, LuminanceAlpha, Luminance, Alpha, RgbaH, LuminanceAlphaH, LuminanceH, AlphaH, Dxt1, Dxt2, Dxt3, Dxt4, or Dxt5 can be specified to the pixel format. However, if the Renderable option is specified, only Rgba, Rgba4444, Rgba5551, or Rgb565 can be specified.

When the pixel format is DXT, the width and height must be a power of 2.

Texture2D ( string  fileName,
bool  mipmap 
)

Creates a 2D texture (from a file)

Parameters:
fileNameFilename
mipmapExistence/Lack of mipmap

Creates a 2D texture from a specified file. The usable file formats are DDS, PNG, JPG, BMP, and GIF (however, animated GIFs are not supported).

When a DDS file, the mipmap argument is ignored. When the pixel format is DXT, the width and height must be a power of 2.

Texture2D ( string  fileName,
bool  mipmap,
PixelFormat  format 
)

Creates a 2D texture (from a file, with format conversion)

Parameters:
fileNameFilename
mipmapExistence/Lack of mipmap
formatPixel format

Creates a 2D texture from a specified file. The usable file formats are DDS, PNG, JPG, BMP, and GIF (however, animated GIFs are not supported). Rgba, Rgba4444, Rgba5551, Rgb565, LuminanceAlpha, Luminance, Alpha, RgbaH, LuminanceAlphaH, LuminanceH, or AlphaH can be specified to the pixel format.

When a DDS file, the mipmap and format arguments are ignored. When the pixel format is DXT, the width and height must be a power of 2.

Texture2D ( byte[]  fileImage,
bool  mipmap 
)

Creates a 2D texture (from a file image)

Parameters:
fileImageFile image
mipmapExistence/Lack of mipmap

Creates a 2D texture from a specified file image. The usable file formats are DDS, PNG, JPG, BMP, and GIF (however, animated GIFs are not supported).

When a DDS file, the mipmap arguments is ignored. When the pixel format is DXT, the width and height must be a power of 2.

Texture2D ( byte[]  fileImage,
bool  mipmap,
PixelFormat  format 
)

Creates a 2D texture (from a file image, with format conversion)

Parameters:
fileImageFile image
mipmapExistence/Lack of mipmap
formatPixel format

Creates a 2D texture from a specified file image. The usable file formats are DDS, PNG, JPG, BMP, and GIF (however, animated GIFs are not supported). Rgba, Rgba4444, Rgba5551, Rgb565, LuminanceAlpha, Luminance, Alpha, RgbaH, LuminanceAlphaH, LuminanceH, or AlphaH can be specified to the pixel format.

When a DDS file, the mipmap and format arguments are ignored. When the pixel format is DXT, the width and height must be a power of 2.

Texture2D ( Texture2D  texture) [protected]

Creates a copy of a 2D texture.

Parameters:
texture2D texture

Creates a copy of the texture. The 2 2D textures will then share unmanaged resources. When Dispose() is called for all copies, the shared unmanaged resources will be freed.


Member Function Documentation

void GenerateMipmap ( )

Automatically creates a mipmap image.

Automatically creates a mipmap image from the current zero level image. Nothing will be performed if mipmaps are not present.

When the pixel format is DXT, nothing will be performed.

void SetPixels ( int  level,
Array  pixels,
int  dx,
int  dy,
int  dw,
int  dh 
)

Sets pixel data (with range)

Parameters:
levelMipmap level (0 to LevelCount-1)
pixelsPixel data
dxX coordinate of the transfer destination
dyY coordinate of the transfer destination
dwWidth of the transfer destination
dhHeight of the transfer destination

Sets the pixel data to the specified mipmap level.

When the pixel format is DXT, the dx, dy, dw, and dh must be a multiple of 4.

void SetPixels ( int  level,
Array  pixels,
PixelFormat  format,
int  offset,
int  pitch,
int  dx,
int  dy,
int  dw,
int  dh 
)

Sets pixel data (with format conversion, with byte offset, with range)

Parameters:
levelMipmap level (0 to LevelCount-1)
pixelsPixel data
formatPixel format
offsetByte offset of pixel data
pitchByte pitch of pixel data
dxX coordinate of the transfer destination
dyY coordinate of the transfer destination
dwWidth of the transfer destination
dhHeight of the transfer destination

Sets the pixel data to the specified mipmap level. Rgba or the same format as the texture can be specified to the pixel format.

When the pixel format is DXT, the dx, dy, dw, and dh must be a multiple of 4. Conversion of DXT pixel format is not supported.

void SetPixels ( int  level,
Array  pixels,
PixelFormat  format 
)

Sets pixel data (with format conversion)

Parameters:
levelMipmap level (0 to LevelCount-1)
pixelsPixel data
formatPixel format

Sets the pixel data to the specified mipmap level. Rgba or the same format as the texture can be specified to the pixel format.

Conversion of DXT pixel format is not supported.

void SetPixels ( int  level,
Array  pixels,
int  offset,
int  pitch 
)

Sets pixel data (with byte offset)

Parameters:
levelMipmap level (0 to LevelCount-1)
pixelsPixel data
offsetByte offset of pixel data
pitchByte pitch of pixel data

Sets the pixel data to the specified mipmap level.

void SetPixels ( int  level,
Array  pixels 
)

Sets pixel data.

Parameters:
levelMipmap level (0 to LevelCount-1)
pixelsPixel data

Sets the pixel data to the specified mipmap level.

This overload sets data to all pixels of the specified mipmap level. When the size of the array differs from the required size, an exception is thrown. When the array size is bigger than the required size, please use a different overload.

override Object ShallowClone ( ) [virtual]

Creates a copy of a 2D texture.

Returns:
Clones a 2D texture

Creates a copy of the texture. The 2 2D textures will then share unmanaged resources. When Dispose() is called for all copies, the shared unmanaged resources will be freed.

Reimplemented from Texture.