Image.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #ifndef IMAGE_H
  2. #define IMAGE_H
  3. #include "Defs.hpp"
  4. #include "Vector2.hpp"
  5. #include "Rect2.hpp"
  6. #include "Color.hpp"
  7. #include "String.hpp"
  8. #include <godot/godot_image.h>
  9. namespace godot {
  10. class PoolByteArray;
  11. class Image {
  12. godot_image _godot_image;
  13. public:
  14. enum Format {
  15. FORMAT_L8, //luminance
  16. FORMAT_LA8, //luminance-alpha
  17. FORMAT_R8,
  18. FORMAT_RG8,
  19. FORMAT_RGB8,
  20. FORMAT_RGBA8,
  21. FORMAT_RGB565, //16 bit
  22. FORMAT_RGBA4444,
  23. FORMAT_RGBA5551,
  24. FORMAT_RF, //float
  25. FORMAT_RGF,
  26. FORMAT_RGBF,
  27. FORMAT_RGBAF,
  28. FORMAT_RH, //half float
  29. FORMAT_RGH,
  30. FORMAT_RGBH,
  31. FORMAT_RGBAH,
  32. FORMAT_DXT1, //s3tc bc1
  33. FORMAT_DXT3, //bc2
  34. FORMAT_DXT5, //bc3
  35. FORMAT_ATI1, //bc4
  36. FORMAT_ATI2, //bc5
  37. FORMAT_BPTC_RGBA, //btpc bc6h
  38. FORMAT_BPTC_RGBF, //float /
  39. FORMAT_BPTC_RGBFU, //unsigned float
  40. FORMAT_PVRTC2, //pvrtc
  41. FORMAT_PVRTC2A,
  42. FORMAT_PVRTC4,
  43. FORMAT_PVRTC4A,
  44. FORMAT_ETC, //etc1
  45. FORMAT_ETC2_R11, //etc2
  46. FORMAT_ETC2_R11S, //signed, NOT srgb.
  47. FORMAT_ETC2_RG11,
  48. FORMAT_ETC2_RG11S,
  49. FORMAT_ETC2_RGB8,
  50. FORMAT_ETC2_RGBA8,
  51. FORMAT_ETC2_RGB8A1,
  52. FORMAT_MAX
  53. };
  54. enum Interpolation {
  55. INTERPOLATE_NEAREST,
  56. INTERPOLATE_BILINEAR,
  57. INTERPOLATE_CUBIC,
  58. /* INTERPOLATE GAUSS */
  59. };
  60. enum CompressMode {
  61. COMPRESS_16BIT,
  62. COMPRESS_S3TC,
  63. COMPRESS_PVRTC2,
  64. COMPRESS_PVRTC4,
  65. COMPRESS_ETC,
  66. COMPRESS_ETC2
  67. };
  68. Image();
  69. Image(const int width, const int height, const bool mipmaps, const Format format);
  70. void blit_rect(const Image& src, const Rect2& src_rect, const Vector2& dest = Vector2(0, 0));
  71. void brush_transfer(const Image& src, const Image& brush, const Vector2& pos = Vector2(0, 0));
  72. Image brushed(const Image& src, const Image& brush, const Vector2& pos = Vector2(0, 0));
  73. Image compressed(const Format format);
  74. Image converted(const Format format);
  75. Image decompressed();
  76. bool empty() const;
  77. void fix_alpha_edges();
  78. PoolByteArray get_data();
  79. Format get_format() const;
  80. int get_height() const;
  81. Color get_pixel(const int x, const int y, const int mipmap_level = 0);
  82. Image get_rect(const Rect2& area = Rect2());
  83. Rect2 get_used_rect() const;
  84. int get_width() const;
  85. Error load(const String& path);
  86. void put_pixel(const int x, const int y, const Color& color, int mipmap_level = 0);
  87. Image resized(const int x, const int y, const Interpolation interpolation = INTERPOLATE_NEAREST);
  88. Error save_png(const String& path);
  89. ~Image();
  90. };
  91. }
  92. #endif // IMAGE_H