Otter  0.9.88
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.Texture Class Reference

Class representing a texture. Can perform pixel operations on the CPU, but those will be pretty slow and shouldn't be used that much. More...

Public Member Functions

 Texture (string source, bool useCache=true)
 Load a texture from a file path. More...
 
 Texture (Stream stream, bool useCache=true)
 Create a texture from a stream of bytes. More...
 
 Texture (Texture copy)
 Creates a new texture from a copy of another texture. No cache option for this. More...
 
 Texture (byte[] bytes, bool useCache=true)
 Create a texture from a byte array. More...
 
 Texture (int width, int height)
 Creates an empty texture of width and height. This does not use the cache. More...
 
void CopyPixels (Texture from, int fromX, int fromY, int toX, int toY)
 Copy pixels from one texture to another using blitting. More...
 
void CopyPixels (Texture from, int fromX, int fromY, int fromWidth, int fromHeight, int toX, int toY)
 
void CreateImage (bool forceNewImage=false)
 Loads the image internally in the texture for image manipulation. This is handled automatically, but it's exposed so that it can be manually controlled. More...
 
Color GetPixel (int x, int y)
 Get the Color from a specific pixel on the texture. Warning: This is slow! More...
 
void SaveToFile (string path)
 Save the texture to a file. The supported image formats are bmp, png, tga and jpg. More...
 
void SetPixel (int x, int y, Color color)
 Sets the color of a specific pixel on the texture. More...
 
void SetRect (int x, int y, int width, int height, Color color)
 Sets the color of a rectangle of pixels on the texture. More...
 
void Update ()
 Updates the texture to reflect changes made from SetPixel. More...
 
void SetBytes (byte[] bytes)
 Updates the texture with a byte array. Note: Updates immediately. Probably not the fastest. More...
 
void SetBytes (byte[] bytes, int width, int height, int x=0, int y=0)
 Updates the texture with a byte array, at the given position and size. Note: Updates immediately. Probably not the fastest. More...
 

Static Public Attributes

static bool DefaultSmooth = false
 The default setting to use for smoothing textures. Much easier to set this at the start of a program rather than adjust the settings for every single texture you use. More...
 

Properties

int Height [get]
 The height of the texture. More...
 
byte[] Pixels [get, set]
 The array of pixels in the texture in bytes. More...
 
Rectangle Region [get]
 The rectangle created by the Texture's width and height. More...
 
bool Smooth [get, set]
 Determines if the source texture is smoothed when transformed. More...
 
string Source [get, set]
 The file path source if the texture was loaded from a file. More...
 
int Width [get]
 The width of the Texture. More...
 

Detailed Description

Class representing a texture. Can perform pixel operations on the CPU, but those will be pretty slow and shouldn't be used that much.

Constructor & Destructor Documentation

Otter.Texture.Texture ( string  source,
bool  useCache = true 
)

Load a texture from a file path.

Parameters
sourceThe file path to load from.
useCacheDetermines if the cache should be checked first.
Otter.Texture.Texture ( Stream  stream,
bool  useCache = true 
)

Create a texture from a stream of bytes.

Parameters
streamThe stream to load from.
useCacheDetermines if the cache should be checked first.
Otter.Texture.Texture ( Texture  copy)

Creates a new texture from a copy of another texture. No cache option for this.

Parameters
copyThe texture to copy from.
Otter.Texture.Texture ( byte[]  bytes,
bool  useCache = true 
)

Create a texture from a byte array.

Parameters
bytesThe byte array to load from.
useCacheDetermines if the cache should be checked first.
Otter.Texture.Texture ( int  width,
int  height 
)

Creates an empty texture of width and height. This does not use the cache.

Parameters
widthThe width of the texture.
heightThe height of the texture.

Member Function Documentation

void Otter.Texture.CopyPixels ( Texture  from,
int  fromX,
int  fromY,
int  toX,
int  toY 
)

Copy pixels from one texture to another using blitting.

Parameters
from
fromX
fromY
toX
toY
void Otter.Texture.CreateImage ( bool  forceNewImage = false)

Loads the image internally in the texture for image manipulation. This is handled automatically, but it's exposed so that it can be manually controlled.

Parameters
forceNewImageIf set to true a new image will always be created instead of only when there is no image.
Color Otter.Texture.GetPixel ( int  x,
int  y 
)

Get the Color from a specific pixel on the texture. Warning: This is slow!

Parameters
xThe x coordinate of the pixel to get.
yThe y coordinate of the pixel to get.
Returns
The Color of the pixel.
void Otter.Texture.SaveToFile ( string  path)

Save the texture to a file. The supported image formats are bmp, png, tga and jpg.

Parameters
pathThe file path to save to. The type of image is deduced from the extension.
void Otter.Texture.SetBytes ( byte[]  bytes)

Updates the texture with a byte array. Note: Updates immediately. Probably not the fastest.

Parameters
bytesThe byte array containing our pixels.
void Otter.Texture.SetBytes ( byte[]  bytes,
int  width,
int  height,
int  x = 0,
int  y = 0 
)

Updates the texture with a byte array, at the given position and size. Note: Updates immediately. Probably not the fastest.

Parameters
bytesThe byte array containing our pixels.
widthThe width of the section we are updating.
heightThe height of the section we are updating.
xThe X coordinate of the section we are updating.
yThe Y coordinate of the section we are updating.
void Otter.Texture.SetPixel ( int  x,
int  y,
Color  color 
)

Sets the color of a specific pixel on the texture.

Parameters
xThe x coordinate of the pixel.
yThe y coordinate of the pixel.
colorThe Color to set the pixel to.
void Otter.Texture.SetRect ( int  x,
int  y,
int  width,
int  height,
Color  color 
)

Sets the color of a rectangle of pixels on the texture.

Parameters
xThe x coordinate of the rectangle.
yThe y coordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
colorThe color of the rectangle.
void Otter.Texture.Update ( )

Updates the texture to reflect changes made from SetPixel.

Member Data Documentation

bool Otter.Texture.DefaultSmooth = false
static

The default setting to use for smoothing textures. Much easier to set this at the start of a program rather than adjust the settings for every single texture you use.

Property Documentation

int Otter.Texture.Height
get

The height of the texture.

byte [] Otter.Texture.Pixels
getset

The array of pixels in the texture in bytes.

Rectangle Otter.Texture.Region
get

The rectangle created by the Texture's width and height.

bool Otter.Texture.Smooth
getset

Determines if the source texture is smoothed when transformed.

string Otter.Texture.Source
getset

The file path source if the texture was loaded from a file.

int Otter.Texture.Width
get

The width of the Texture.


The documentation for this class was generated from the following file: