Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ImageGroupAsset.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 using System.ComponentModel;
3 
4 using SiliconStudio.Assets;
5 using SiliconStudio.Core;
6 using SiliconStudio.Core.IO;
7 using SiliconStudio.Core.Mathematics;
8 using SiliconStudio.Paradox.Assets.Texture;
9 
10 namespace SiliconStudio.Paradox.Assets
11 {
12  /// <summary>
13  /// Describes an image group asset.
14  /// </summary>
15  [DataContract("ImageGroupBase")]
16  public abstract class ImageGroupAsset : Asset
17  {
18  protected ImageGroupAsset()
19  {
20  SetDefaults();
21  }
22 
23  /// <summary>
24  /// 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.
25  /// </summary>
26  /// <value>The color key.</value>
27  [DataMember(20)]
28  public Color ColorKeyColor { get; set; }
29 
30  /// <summary>
31  /// Gets or sets a value indicating whether to enable color key. Default is false.
32  /// </summary>
33  /// <value><c>true</c> to enable color key; otherwise, <c>false</c>.</value>
34  [DataMember(30)]
35  [DefaultValue(false)]
36  public bool ColorKeyEnabled { get; set; }
37 
38  /// <summary>
39  /// Gets or sets the texture format.
40  /// </summary>
41  /// <value>The texture format.</value>
42  [DataMember(40)]
43  [DefaultValue(TextureFormat.Compressed)]
44  public TextureFormat Format { get; set; }
45 
46  /// <summary>
47  /// Gets or sets the alpha format.
48  /// </summary>
49  /// <value>The alpha format.</value>
50  [DataMember(50)]
51  [DefaultValue(AlphaFormat.Interpolated)]
52  public AlphaFormat Alpha { get; set; }
53 
54  /// <summary>
55  /// Gets or sets a value indicating whether [generate mipmaps].
56  /// </summary>
57  /// <value><c>true</c> if [generate mipmaps]; otherwise, <c>false</c>.</value>
58  [DataMember(60)]
59  [DefaultValue(false)]
60  public bool GenerateMipmaps { get; set; }
61 
62  /// <summary>
63  /// Gets or sets a value indicating whether to convert the texture in pre-multiply alpha.
64  /// </summary>
65  /// <value><c>true</c> to convert the texture in pre-multiply alpha.; otherwise, <c>false</c>.</value>
66  [DataMember(70)]
67  [DefaultValue(true)]
68  public bool PremultiplyAlpha { get; set; }
69 
70  public override void SetDefaults()
71  {
72  Format = TextureFormat.Compressed;
73  Alpha = AlphaFormat.Interpolated;
74  ColorKeyColor = new Color(255, 0, 255);
75  ColorKeyEnabled = false;
76  GenerateMipmaps = false;
77  PremultiplyAlpha = true;
78  }
79 
80  public static string BuildTextureUrl(UFile textureAbsolutePath, int spriteIndex)
81  {
82  return textureAbsolutePath + "__IMAGE_TEXTURE__" + spriteIndex;
83  }
84  }
85 
86  /// <summary>
87  /// Describes an image group asset.
88  /// </summary>
89  [DataContract("ImageGroup")]
90  public abstract class ImageGroupAsset<TImage> : ImageGroupAsset
91  {
92  protected ImageGroupAsset()
93  {
94  SetDefaults();
95  }
96 
97  /// <summary>
98  /// Gets or sets the sprites of the group.
99  /// </summary>
100  [DataMember(10)]
101  public List<TImage> Images { get; set; }
102 
103  public override void SetDefaults()
104  {
105  base.SetDefaults();
106  Images = new List<TImage>();
107  }
108  }
109 }
Base class for Asset.
Definition: Asset.cs:14
static string BuildTextureUrl(UFile textureAbsolutePath, int spriteIndex)
SiliconStudio.Core.Mathematics.Color Color
Definition: ColorPicker.cs:14
override void SetDefaults()
Sets the defaults values for this instance
Represents a 32-bit color (4 bytes) in the form of RGBA (in byte order: R, G, B, A).
Definition: Color.cs:16
override void SetDefaults()
Sets the defaults values for this instance
HRESULT PremultiplyAlpha(_In_ const Image &srcImage, _In_ DWORD flags, _Out_ ScratchImage &image)
Defines a normalized file path. See UPath for details. This class cannot be inherited.
Definition: UFile.cs:13
Describes an image group asset.