Table of Contents

Class Texture

Namespace
Fantas
Assembly
Fantas.dll

Texture

public sealed class Texture : IDisposable
Inheritance
Texture
Implements
Inherited Members

Properties

ColorPixelData

Get pixel data as int[]

public Color[] ColorPixelData { get; }

Property Value

Color[]

Height

public float Height { get; }

Property Value

float

PixelData

Get pixel data as int[]

public int[] PixelData { get; }

Property Value

int[]

PixelTexture

1x1 pixel texture

public static Texture PixelTexture { get; }

Property Value

Texture

RawHeight

Texture Raw height (independent of retina scale)

public float RawHeight { get; }

Property Value

float

RawSize

Texture Raw Size (independent of retina scale)

public SizeF RawSize { get; }

Property Value

SizeF

RawWidth

Texture Raw width (independent of retina scale)

public float RawWidth { get; }

Property Value

float

Size

Texture Size

public SizeF Size { get; }

Property Value

SizeF

SparkTexture

Spark texture used by ParticleEmitter

public static Texture SparkTexture { get; }

Property Value

Texture

TextureRectangle

Texture rectangle inside if is subtexture or texture from atlas

public RectangleF TextureRectangle { get; }

Property Value

RectangleF

Width

Texture width

public float Width { get; }

Property Value

float

Methods

CreateSubTexture(RectangleF, Texture)

Create a sub texture from a texture with Rectangle based on 0 - 1f

public static Texture CreateSubTexture(RectangleF rectangle, Texture texture)

Parameters

rectangle RectangleF
texture Texture

Returns

Texture

CreateSubTexture(int, int, int, int, Texture)

Create sub texture using integer coordinates

public static Texture CreateSubTexture(int x, int y, int width, int heigh, Texture texture)

Parameters

x int
y int
width int
heigh int
texture Texture

Returns

Texture

Dispose()

Dispose Texture from VRAM

public void Dispose()

EncodeToPNG()

Encode texture as PNG image in the byte[]

public byte[] EncodeToPNG()

Returns

byte[]

Return current texture encoded in PNG as a byte array

~Texture()

Finalizer

protected ~Texture()

FromAsset(string)

Loads a texture from a native asset Fantas will try to load from the native asset like Image assets on iOS drawable resources on Android MonoGame XNB Content on .NET from Contents/

public static Texture FromAsset(string assetName)

Parameters

assetName string

asset lookup name

Returns

Texture

FromColorPixel(Color)

Create 1x1 color texture

public static Texture FromColorPixel(Color color)

Parameters

color Color

Returns

Texture

FromFile(string)

Load a texture from an file path trying to match the screen-scale

public static Texture FromFile(string file)

Parameters

file string

Returns

Texture

FromFile(string, float)

Load a texture from an file path

public static Texture FromFile(string file, float scale)

Parameters

file string
scale float

Returns

Texture

FromName(string)

Load a texture by name FromName will try to find the texture in different locations using the order:

  • Native Asset
  • Embedded Resource
  • File
public static Texture FromName(string name)

Parameters

name string

Returns

Texture

FromPixelData(Color[], int, int)

Create an Texture from pixel data

public static Texture FromPixelData(Color[] pixelData, int width, int height)

Parameters

pixelData Color[]

pixel data with color as Color array

width int
height int

Returns

Texture

Exceptions

ArgumentNullException
ArgumentException

FromPixelData(int[], int, int)

Create an Texture from pixel data

public static Texture FromPixelData(int[] pixelData, int width, int height)

Parameters

pixelData int[]

pixel data with color encoded as 0xAARRGGBB

width int

texture width

height int

texture height

Returns

Texture

Exceptions

ArgumentNullException

FromResource(Assembly, string, float)

Load a texture from a resource image using the given scale

public static Texture FromResource(Assembly assembly, string resourceName, float scale)

Parameters

assembly Assembly
resourceName string
scale float

image scale

Returns

Texture

FromResource(string)

Load a texture from a resource image It will look on ALL loaded assemblies

public static Texture FromResource(string resourceName)

Parameters

resourceName string

Returns

Texture

FromResource(string, float)

Load a texture from a resource image, using the given scale It will look on ALL loaded assemblies

public static Texture FromResource(string resourceName, float scale)

Parameters

resourceName string
scale float

Returns

Texture

FromResourceCached(Assembly, string, float)

Load a texture from a resource and cache it for future use

public static Texture FromResourceCached(Assembly assembly, string resourceName, float scale)

Parameters

assembly Assembly
resourceName string
scale float

Returns

Texture

FromStream(Stream, float)

Load a texture from a stream (with scale) Using given scale

public static Texture FromStream(Stream stream, float scale)

Parameters

stream Stream
scale float

Returns

Texture

RemoveTextureFromCache(Texture)

Remove cached from Cache (will be called by Dispose)

public static void RemoveTextureFromCache(Texture texture)

Parameters

texture Texture