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
PixelData
Get pixel data as int[]
public int[] PixelData { get; }
Property Value
- int[]
PixelTexture
1x1 pixel texture
public static Texture PixelTexture { get; }
Property Value
RawHeight
Texture Raw height (independent of retina scale)
public float RawHeight { get; }
Property Value
RawSize
Texture Raw Size (independent of retina scale)
public SizeF RawSize { get; }
Property Value
RawWidth
Texture Raw width (independent of retina scale)
public float RawWidth { get; }
Property Value
Size
Texture Size
public SizeF Size { get; }
Property Value
SparkTexture
Spark texture used by ParticleEmitter
public static Texture SparkTexture { get; }
Property Value
TextureRectangle
Texture rectangle inside if is subtexture or texture from atlas
public RectangleF TextureRectangle { get; }
Property Value
Width
Texture width
public float Width { get; }
Property Value
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
RectangleFtexture
Texture
Returns
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
Returns
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
stringasset lookup name
Returns
FromColorPixel(Color)
Create 1x1 color texture
public static Texture FromColorPixel(Color color)
Parameters
color
Color
Returns
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
FromFile(string, float)
Load a texture from an file path
public static Texture FromFile(string file, float scale)
Parameters
Returns
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
FromPixelData(Color[], int, int)
Create an Texture from pixel data
public static Texture FromPixelData(Color[] pixelData, int width, int height)
Parameters
Returns
Exceptions
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
inttexture width
height
inttexture height
Returns
Exceptions
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
Returns
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
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
Returns
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
Returns
FromStream(Stream, float)
Load a texture from a stream (with scale) Using given scale
public static Texture FromStream(Stream stream, float scale)
Parameters
Returns
RemoveTextureFromCache(Texture)
Remove cached from Cache (will be called by Dispose)
public static void RemoveTextureFromCache(Texture texture)
Parameters
texture
Texture