Image.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #ifndef IMAGE_H
  2. #define IMAGE_H
  3. #include "Defs.h"
  4. #include "Vector2.h"
  5. #include "Rect2.h"
  6. #include "Color.h"
  7. #include "String.h"
  8. #include <godot/godot_image.h>
  9. namespace godot {
  10. class Image {
  11. godot_image _godot_image;
  12. public:
  13. enum Format {
  14. FORMAT_L8, //luminance
  15. FORMAT_LA8, //luminance-alpha
  16. FORMAT_R8,
  17. FORMAT_RG8,
  18. FORMAT_RGB8,
  19. FORMAT_RGBA8,
  20. FORMAT_RGB565, //16 bit
  21. FORMAT_RGBA4444,
  22. FORMAT_RGBA5551,
  23. FORMAT_RF, //float
  24. FORMAT_RGF,
  25. FORMAT_RGBF,
  26. FORMAT_RGBAF,
  27. FORMAT_RH, //half float
  28. FORMAT_RGH,
  29. FORMAT_RGBH,
  30. FORMAT_RGBAH,
  31. FORMAT_DXT1, //s3tc bc1
  32. FORMAT_DXT3, //bc2
  33. FORMAT_DXT5, //bc3
  34. FORMAT_ATI1, //bc4
  35. FORMAT_ATI2, //bc5
  36. FORMAT_BPTC_RGBA, //btpc bc6h
  37. FORMAT_BPTC_RGBF, //float /
  38. FORMAT_BPTC_RGBFU, //unsigned float
  39. FORMAT_PVRTC2, //pvrtc
  40. FORMAT_PVRTC2A,
  41. FORMAT_PVRTC4,
  42. FORMAT_PVRTC4A,
  43. FORMAT_ETC, //etc1
  44. FORMAT_ETC2_R11, //etc2
  45. FORMAT_ETC2_R11S, //signed, NOT srgb.
  46. FORMAT_ETC2_RG11,
  47. FORMAT_ETC2_RG11S,
  48. FORMAT_ETC2_RGB8,
  49. FORMAT_ETC2_RGBA8,
  50. FORMAT_ETC2_RGB8A1,
  51. FORMAT_MAX
  52. };
  53. enum Interpolation {
  54. INTERPOLATE_NEAREST,
  55. INTERPOLATE_BILINEAR,
  56. INTERPOLATE_CUBIC,
  57. /* INTERPOLATE GAUSS */
  58. };
  59. enum CompressMode {
  60. COMPRESS_16BIT,
  61. COMPRESS_S3TC,
  62. COMPRESS_PVRTC2,
  63. COMPRESS_PVRTC4,
  64. COMPRESS_ETC,
  65. COMPRESS_ETC2
  66. };
  67. Image()
  68. {
  69. godot_image_new(&_godot_image);
  70. }
  71. Image(const int width, const int height, const bool mipmaps, const Format format)
  72. {
  73. godot_image_new_with_size_format(&_godot_image, width, height, mipmaps, (godot_image_format) format);
  74. }
  75. void blit_rect(const Image& src, const Rect2& src_rect, const Vector2& dest = Vector2(0, 0))
  76. {
  77. // @DLScript @Todo
  78. }
  79. void brush_transfer(const Image& src, const Image& brush, const Vector2& pos = Vector2(0, 0))
  80. {
  81. // @DLScript @Todo
  82. }
  83. Image brushed(const Image& src, const Image& brush, const Vector2& pos = Vector2(0, 0))
  84. {
  85. return *this; // @DLScript @Todo
  86. }
  87. Image compressed(const Format format)
  88. {
  89. return *this; // @DLScript @Todo
  90. }
  91. Image converted(const Format format)
  92. {
  93. return *this; // @DLScript @Todo
  94. }
  95. Image decompressed()
  96. {
  97. return *this; // @DLScript @Todo
  98. }
  99. bool empty() const
  100. {
  101. return true; // @DLScript @Todo
  102. }
  103. void fix_alpha_edges()
  104. {
  105. // @DLScript @Todo
  106. }
  107. /*
  108. PoolByteArray get_data()
  109. {
  110. // @Todo
  111. }
  112. */
  113. Format get_format() const
  114. {
  115. return Format::FORMAT_RGBAH; // @DLScript @Todo
  116. }
  117. int get_height() const
  118. {
  119. return godot_image_get_height(&_godot_image);
  120. }
  121. Color get_pixel(const int x, const int y, const int mipmap_level = 0)
  122. {
  123. return Color(); // @DLScript @Todo
  124. }
  125. Image get_rect(const Rect2& area = Rect2())
  126. {
  127. return *this; // @DLScript @Todo
  128. }
  129. Rect2 get_used_rect() const
  130. {
  131. return Rect2(); // @DLScript @Todo
  132. }
  133. int get_width() const
  134. {
  135. return godot_image_get_width(&_godot_image);
  136. }
  137. Error load(const String& path)
  138. {
  139. return (Error) godot_image_load(&_godot_image, (godot_string *) &path);
  140. }
  141. void put_pixel(const int x, const int y, const Color& color, int mipmap_level = 0)
  142. {
  143. // @DLScript @Todo
  144. }
  145. Image resized(const int x, const int y, const Interpolation interpolation = INTERPOLATE_NEAREST)
  146. {
  147. return *this; // @DLScript @Todo
  148. }
  149. Error save_png(const String& path)
  150. {
  151. return (Error) godot_image_save_png(&_godot_image, (godot_string *) &path); // @Todo Error enum
  152. }
  153. ~Image()
  154. {
  155. godot_image_destroy(&_godot_image);
  156. }
  157. };
  158. }
  159. #endif // IMAGE_H