Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TextureAsset.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System.ComponentModel;
4 using SiliconStudio.Assets;
5 using SiliconStudio.Assets.Compiler;
6 using SiliconStudio.Core;
7 using SiliconStudio.Core.Mathematics;
8 
9 namespace SiliconStudio.Paradox.Assets.Texture
10 {
11  /// <summary>
12  /// Describes a texture asset.
13  /// </summary>
14  [DataContract("Texture")]
15  [AssetFileExtension(FileExtension)]
16  [AssetCompiler(typeof(TextureAssetCompiler))]
17  [ThumbnailCompiler(PreviewerCompilerNames.TextureThumbnailCompilerQualifiedName)]
18  [AssetDescription("Texture", "A texture", true)]
19  public sealed class TextureAsset : AssetImport
20  {
21  /// <summary>
22  /// The default file extension used by the <see cref="TextureAsset"/>.
23  /// </summary>
24  public const string FileExtension = ".pdxtex";
25 
26  /// <summary>
27  /// Initializes a new instance of the <see cref="TextureAsset"/> class.
28  /// </summary>
29  public TextureAsset()
30  {
31  SetDefaults();
32  }
33 
34  /// <summary>
35  /// Gets or sets the width.
36  /// </summary>
37  /// <value>The width.</value>
38  /// <userdoc>
39  /// The width of the texture in-game. Depending on the value of the IsSizeInPercentage property, the value might represent either percent (%) or actual pixel.
40  /// </userdoc>
41  [DataMember(20)]
42  [DefaultValue(100.0f)]
43  [StepRangeAttribute(0, 10000, 1, 10)]
44  public float Width { get; set; }
45 
46  /// <summary>
47  /// Gets or sets the height.
48  /// </summary>
49  /// <value>The height.</value>
50  /// <userdoc>
51  /// The height of the texture in-game. Depending on the value of the IsSizeInPercentage property, the value might represent either percent (%) or actual pixel.
52  /// </userdoc>
53  [DataMember(30)]
54  [DefaultValue(100.0f)]
55  [StepRangeAttribute(0, 10000, 1, 10)]
56  public float Height { get; set; }
57 
58  /// <summary>
59  /// Gets or sets a value indicating whether this instance is using size in percentage. Default is true. See remarks.
60  /// </summary>
61  /// <value><c>true</c> if this instance is dimension absolute; otherwise, <c>false</c>.</value>
62  /// <remarks>
63  /// When this property is true (by default), <see cref="Width"/> and <see cref="Height"/> are epxressed
64  /// in percentage, with 100.0f being 100% of the current size, and 50.0f half of the current size, otherwise
65  /// the size is in absolute pixels.
66  /// </remarks>
67  /// <userdoc>
68  /// If checked, the values of the Width and Height properties will represent percent (%). Otherwise they would represent actual pixel.
69  /// </userdoc>
70  [DataMember(40)]
71  [DefaultValue(true)]
72  public bool IsSizeInPercentage { get; set; }
73 
74  /// <summary>
75  /// Gets or sets a value indicating whether to enable color key. Default is false.
76  /// </summary>
77  /// <value><c>true</c> to enable color key; otherwise, <c>false</c>.</value>
78  /// <userdoc>
79  /// If checked, all pixels of the color set in the ColorKeyColor property will be replaced by transparent black.
80  /// </userdoc>
81  [DataMember(43)]
82  [DefaultValue(false)]
83  public bool ColorKeyEnabled { get; set; }
84 
85  /// <summary>
86  /// Gets or sets the color key used when color keying for a texture is enabled. When color keying, all pixels of a specified color are replaced with transparent black.
87  /// </summary>
88  /// <value>The color key.</value>
89  /// <userdoc>
90  /// If ColorKeyEnabled is true, All pixels of the color set to this property are replaced with transparent black.
91  /// </userdoc>
92  [DataMember(45)]
93  public Color ColorKeyColor { get; set; }
94 
95  /// <summary>
96  /// Gets or sets the texture format.
97  /// </summary>
98  /// <value>The texture format.</value>
99  /// <userdoc>
100  /// The format to use for the texture. If Compressed, the final texture size must be a multiple of 4.
101  /// </userdoc>
102  [DataMember(50)]
103  [DefaultValue(TextureFormat.Compressed)]
104  public TextureFormat Format { get; set; }
105 
106  /// <summary>
107  /// Gets or sets the alpha format.
108  /// </summary>
109  /// <value>The alpha format.</value>
110  /// <userdoc>
111  /// The format to use for alpha in the texture.
112  /// </userdoc>
113  [DataMember(55)]
114  [DefaultValue(AlphaFormat.None)]
115  public AlphaFormat Alpha { get; set; }
116 
117  /// <summary>
118  /// Gets or sets a value indicating whether to generate mipmaps.
119  /// </summary>
120  /// <value><c>true</c> if mipmaps are generated; otherwise, <c>false</c>.</value>
121  /// <userdoc>
122  /// If checked, Mipmaps will be pre-generated for this texture.
123  /// </userdoc>
124  [DataMember(60)]
125  [DefaultValue(true)]
126  public bool GenerateMipmaps { get; set; }
127 
128  /// <summary>
129  /// Gets or sets a value indicating whether to convert the texture in premultiply alpha.
130  /// </summary>
131  /// <value><c>true</c> to convert the texture in premultiply alpha.; otherwise, <c>false</c>.</value>
132  /// <userdoc>
133  /// If checked, The color values will be pre-multiplied by the alpha value.
134  /// </userdoc>
135  [DataMember(70)]
136  [DefaultValue(true)]
137  public bool PremultiplyAlpha { get; set; }
138 
139  public override void SetDefaults()
140  {
141  Width = 100.0f;
142  Height = 100.0f;
143  Format = TextureFormat.Compressed;
144  Alpha = AlphaFormat.None;
145  ColorKeyColor = new Color(255, 0, 255);
146  ColorKeyEnabled = false;
147  IsSizeInPercentage = true;
148  GenerateMipmaps = true;
149  PremultiplyAlpha = true;
150  }
151  }
152 }
override void SetDefaults()
Sets the defaults values for this instance
TextureAsset()
Initializes a new instance of the TextureAsset class.
Definition: TextureAsset.cs:29
SiliconStudio.Core.Mathematics.Color Color
Definition: ColorPicker.cs:14
Represents a 32-bit color (4 bytes) in the form of RGBA (in byte order: R, G, B, A).
Definition: Color.cs:16
Same as Deferred mode, except sprites are sorted by texture prior to drawing. This can improve perfor...
An importable asset.
Definition: AssetImport.cs:14
This attribute allows to define boundaries for a numeric property, and advice small and large increme...
Contains user-friendly names and descriptions of an asset type.
HRESULT PremultiplyAlpha(_In_ const Image &srcImage, _In_ DWORD flags, _Out_ ScratchImage &image)