Texture2DWrapper.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System.IO;
  4. namespace OpenVIII
  5. {
  6. public class Texture2DWrapper : Texture_Base
  7. {
  8. #region Fields
  9. private Texture2D _tex;
  10. #endregion Fields
  11. #region Constructors
  12. public Texture2DWrapper(Texture2D tex) => _tex = tex;
  13. #endregion Constructors
  14. #region Properties
  15. public override byte GetBytesPerPixel => 4;
  16. public override int GetClutCount => 0;
  17. public override int GetClutSize => 0;
  18. public override int GetColorsCountPerPalette => 0;
  19. public override int GetHeight => _tex?.Height ?? 0;
  20. public override int GetOrigX => 0;
  21. public override int GetOrigY => 0;
  22. public override int GetWidth => _tex?.Width ?? 0;
  23. #endregion Properties
  24. #region Methods
  25. public static implicit operator Texture2D(Texture2DWrapper right) => right._tex;
  26. public static implicit operator Texture2DWrapper(Texture2D right) => new Texture2DWrapper(right);
  27. public override void ForceSetClutColors(ushort newNumOfColors)
  28. {
  29. }
  30. public override void ForceSetClutCount(ushort newClut)
  31. {
  32. }
  33. public override Color[] GetClutColors(ushort clut) => null;
  34. public override Texture2D GetTexture() => _tex;
  35. public override Texture2D GetTexture(Color[] colors) => _tex;
  36. public override Texture2D GetTexture(ushort clut) => _tex;
  37. public override void Load(byte[] buffer, uint offset = 0) => throw new System.NotImplementedException("This class must use Load(Texture2D)");
  38. public void Load(Texture2D inputTex) => _tex = inputTex;
  39. public override void Save(string path)
  40. {
  41. Extended.Save_As_PNG(_tex, path, _tex.Width, _tex.Height);
  42. }
  43. public override void SaveCLUT(string path)
  44. { // no clut data.
  45. }
  46. #endregion Methods
  47. }
  48. }