image.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. /**************************************************************************/
  2. /* image.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #pragma once
  31. #include "core/io/resource.h"
  32. #include "core/math/color.h"
  33. /**
  34. * Image storage class. This is used to store an image in user memory, as well as
  35. * providing some basic methods for image manipulation.
  36. * Images can be loaded from a file, or registered into the Render object as textures.
  37. */
  38. class Image;
  39. // Function pointer prototypes.
  40. typedef Error (*SavePNGFunc)(const String &p_path, const Ref<Image> &p_img);
  41. typedef Vector<uint8_t> (*SavePNGBufferFunc)(const Ref<Image> &p_img);
  42. typedef Error (*SaveJPGFunc)(const String &p_path, const Ref<Image> &p_img, float p_quality);
  43. typedef Vector<uint8_t> (*SaveJPGBufferFunc)(const Ref<Image> &p_img, float p_quality);
  44. typedef Ref<Image> (*ImageMemLoadFunc)(const uint8_t *p_data, int p_size);
  45. typedef Ref<Image> (*ScalableImageMemLoadFunc)(const uint8_t *p_data, int p_size, float p_scale);
  46. typedef Error (*SaveWebPFunc)(const String &p_path, const Ref<Image> &p_img, const bool p_lossy, const float p_quality);
  47. typedef Vector<uint8_t> (*SaveWebPBufferFunc)(const Ref<Image> &p_img, const bool p_lossy, const float p_quality);
  48. typedef Error (*SaveEXRFunc)(const String &p_path, const Ref<Image> &p_img, bool p_grayscale);
  49. typedef Vector<uint8_t> (*SaveEXRBufferFunc)(const Ref<Image> &p_img, bool p_grayscale);
  50. typedef Error (*SaveDDSFunc)(const String &p_path, const Ref<Image> &p_img);
  51. typedef Vector<uint8_t> (*SaveDDSBufferFunc)(const Ref<Image> &p_img);
  52. class Image : public Resource {
  53. GDCLASS(Image, Resource);
  54. public:
  55. enum {
  56. MAX_WIDTH = (1 << 24), // Force a limit somehow.
  57. MAX_HEIGHT = (1 << 24), // Force a limit somehow.
  58. MAX_PIXELS = 268435456 // 16384 ^ 2
  59. };
  60. enum Format : int32_t {
  61. FORMAT_L8, // Luminance
  62. FORMAT_LA8, // Luminance-Alpha
  63. FORMAT_R8,
  64. FORMAT_RG8,
  65. FORMAT_RGB8,
  66. FORMAT_RGBA8,
  67. FORMAT_RGBA4444,
  68. FORMAT_RGB565,
  69. FORMAT_RF, // Float
  70. FORMAT_RGF,
  71. FORMAT_RGBF,
  72. FORMAT_RGBAF,
  73. FORMAT_RH, // Half
  74. FORMAT_RGH,
  75. FORMAT_RGBH,
  76. FORMAT_RGBAH,
  77. FORMAT_RGBE9995,
  78. FORMAT_DXT1, // BC1
  79. FORMAT_DXT3, // BC2
  80. FORMAT_DXT5, // BC3
  81. FORMAT_RGTC_R, // BC4
  82. FORMAT_RGTC_RG, // BC5
  83. FORMAT_BPTC_RGBA, // BC7
  84. FORMAT_BPTC_RGBF, // BC6 Signed
  85. FORMAT_BPTC_RGBFU, // BC6 Unsigned
  86. FORMAT_ETC, // ETC1
  87. FORMAT_ETC2_R11,
  88. FORMAT_ETC2_R11S, // Signed, NOT srgb.
  89. FORMAT_ETC2_RG11,
  90. FORMAT_ETC2_RG11S, // Signed, NOT srgb.
  91. FORMAT_ETC2_RGB8,
  92. FORMAT_ETC2_RGBA8,
  93. FORMAT_ETC2_RGB8A1,
  94. FORMAT_ETC2_RA_AS_RG, // ETC2 RGBA with a RA-RG swizzle for normal maps.
  95. FORMAT_DXT5_RA_AS_RG, // BC3 with a RA-RG swizzle for normal maps.
  96. FORMAT_ASTC_4x4,
  97. FORMAT_ASTC_4x4_HDR,
  98. FORMAT_ASTC_8x8,
  99. FORMAT_ASTC_8x8_HDR,
  100. FORMAT_MAX
  101. };
  102. static const char *format_names[FORMAT_MAX];
  103. enum Interpolation {
  104. INTERPOLATE_NEAREST,
  105. INTERPOLATE_BILINEAR,
  106. INTERPOLATE_CUBIC,
  107. INTERPOLATE_TRILINEAR,
  108. INTERPOLATE_LANCZOS,
  109. // INTERPOLATE_TRICUBIC,
  110. // INTERPOLATE_GAUSS
  111. };
  112. // Used for obtaining optimal compression quality.
  113. enum UsedChannels {
  114. USED_CHANNELS_L,
  115. USED_CHANNELS_LA,
  116. USED_CHANNELS_R,
  117. USED_CHANNELS_RG,
  118. USED_CHANNELS_RGB,
  119. USED_CHANNELS_RGBA,
  120. };
  121. // ASTC supports block formats other than 4x4.
  122. enum ASTCFormat {
  123. ASTC_FORMAT_4x4,
  124. ASTC_FORMAT_8x8,
  125. };
  126. enum RoughnessChannel {
  127. ROUGHNESS_CHANNEL_R,
  128. ROUGHNESS_CHANNEL_G,
  129. ROUGHNESS_CHANNEL_B,
  130. ROUGHNESS_CHANNEL_A,
  131. ROUGHNESS_CHANNEL_L,
  132. };
  133. enum Image3DValidateError {
  134. VALIDATE_3D_OK,
  135. VALIDATE_3D_ERR_IMAGE_EMPTY,
  136. VALIDATE_3D_ERR_MISSING_IMAGES,
  137. VALIDATE_3D_ERR_EXTRA_IMAGES,
  138. VALIDATE_3D_ERR_IMAGE_SIZE_MISMATCH,
  139. VALIDATE_3D_ERR_IMAGE_FORMAT_MISMATCH,
  140. VALIDATE_3D_ERR_IMAGE_HAS_MIPMAPS,
  141. };
  142. enum CompressMode {
  143. COMPRESS_S3TC,
  144. COMPRESS_ETC,
  145. COMPRESS_ETC2,
  146. COMPRESS_BPTC,
  147. COMPRESS_ASTC,
  148. COMPRESS_MAX,
  149. };
  150. enum CompressSource {
  151. COMPRESS_SOURCE_GENERIC,
  152. COMPRESS_SOURCE_SRGB,
  153. COMPRESS_SOURCE_NORMAL,
  154. COMPRESS_SOURCE_MAX,
  155. };
  156. enum AlphaMode {
  157. ALPHA_NONE,
  158. ALPHA_BIT,
  159. ALPHA_BLEND
  160. };
  161. struct BasisUniversalPackerParams {
  162. int uastc_level = 0;
  163. float rdo_quality_loss = 0;
  164. };
  165. // External saver function pointers.
  166. static inline SavePNGFunc save_png_func = nullptr;
  167. static inline SaveJPGFunc save_jpg_func = nullptr;
  168. static inline SaveEXRFunc save_exr_func = nullptr;
  169. static inline SaveWebPFunc save_webp_func = nullptr;
  170. static inline SaveDDSFunc save_dds_func = nullptr;
  171. static inline SavePNGBufferFunc save_png_buffer_func = nullptr;
  172. static inline SaveEXRBufferFunc save_exr_buffer_func = nullptr;
  173. static inline SaveJPGBufferFunc save_jpg_buffer_func = nullptr;
  174. static inline SaveWebPBufferFunc save_webp_buffer_func = nullptr;
  175. static inline SaveDDSBufferFunc save_dds_buffer_func = nullptr;
  176. // External loader function pointers.
  177. static inline ImageMemLoadFunc _png_mem_loader_func = nullptr;
  178. static inline ImageMemLoadFunc _png_mem_unpacker_func = nullptr;
  179. static inline ImageMemLoadFunc _jpg_mem_loader_func = nullptr;
  180. static inline ImageMemLoadFunc _webp_mem_loader_func = nullptr;
  181. static inline ImageMemLoadFunc _tga_mem_loader_func = nullptr;
  182. static inline ImageMemLoadFunc _bmp_mem_loader_func = nullptr;
  183. static inline ScalableImageMemLoadFunc _svg_scalable_mem_loader_func = nullptr;
  184. static inline ImageMemLoadFunc _ktx_mem_loader_func = nullptr;
  185. static inline ImageMemLoadFunc _dds_mem_loader_func = nullptr;
  186. // External VRAM compression function pointers.
  187. static void (*_image_compress_bc_func)(Image *, UsedChannels p_channels);
  188. static void (*_image_compress_bptc_func)(Image *, UsedChannels p_channels);
  189. static void (*_image_compress_etc1_func)(Image *);
  190. static void (*_image_compress_etc2_func)(Image *, UsedChannels p_channels);
  191. static void (*_image_compress_astc_func)(Image *, ASTCFormat p_format);
  192. static Error (*_image_compress_bptc_rd_func)(Image *, UsedChannels p_channels);
  193. static Error (*_image_compress_bc_rd_func)(Image *, UsedChannels p_channels);
  194. // External VRAM decompression function pointers.
  195. static void (*_image_decompress_bc)(Image *);
  196. static void (*_image_decompress_bptc)(Image *);
  197. static void (*_image_decompress_etc1)(Image *);
  198. static void (*_image_decompress_etc2)(Image *);
  199. static void (*_image_decompress_astc)(Image *);
  200. // External packer function pointers.
  201. static Vector<uint8_t> (*webp_lossy_packer)(const Ref<Image> &p_image, float p_quality);
  202. static Vector<uint8_t> (*webp_lossless_packer)(const Ref<Image> &p_image);
  203. static Vector<uint8_t> (*png_packer)(const Ref<Image> &p_image);
  204. static Vector<uint8_t> (*basis_universal_packer)(const Ref<Image> &p_image, UsedChannels p_channels, const BasisUniversalPackerParams &p_basisu_params);
  205. static Ref<Image> (*webp_unpacker)(const Vector<uint8_t> &p_buffer);
  206. static Ref<Image> (*png_unpacker)(const Vector<uint8_t> &p_buffer);
  207. static Ref<Image> (*basis_universal_unpacker)(const Vector<uint8_t> &p_buffer);
  208. static Ref<Image> (*basis_universal_unpacker_ptr)(const uint8_t *p_data, int p_size);
  209. protected:
  210. virtual Ref<Resource> _duplicate(const DuplicateParams &p_params) const override;
  211. static void _bind_methods();
  212. private:
  213. Format format = FORMAT_L8;
  214. Vector<uint8_t> data;
  215. int width = 0;
  216. int height = 0;
  217. bool mipmaps = false;
  218. void _copy_internals_from(const Image &p_image);
  219. _FORCE_INLINE_ Color _get_color_at_ofs(const uint8_t *ptr, uint32_t ofs) const;
  220. _FORCE_INLINE_ void _set_color_at_ofs(uint8_t *ptr, uint32_t ofs, const Color &p_color);
  221. _FORCE_INLINE_ void _get_mipmap_offset_and_size(int p_mipmap, int64_t &r_offset, int &r_width, int &r_height) const; // Get where the mipmap begins in data.
  222. static int64_t _get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps = -1, int *r_mm_width = nullptr, int *r_mm_height = nullptr);
  223. _FORCE_INLINE_ void _get_clipped_src_and_dest_rects(const Ref<Image> &p_src, const Rect2i &p_src_rect, const Point2i &p_dest, Rect2i &r_clipped_src_rect, Rect2i &r_clipped_dest_rect) const;
  224. _FORCE_INLINE_ void _put_pixelb(int p_x, int p_y, uint32_t p_pixel_size, uint8_t *p_data, const uint8_t *p_pixel);
  225. _FORCE_INLINE_ void _get_pixelb(int p_x, int p_y, uint32_t p_pixel_size, const uint8_t *p_data, uint8_t *p_pixel);
  226. _FORCE_INLINE_ void _repeat_pixel_over_subsequent_memory(uint8_t *p_pixel, int p_pixel_size, int p_count);
  227. void _set_data(const Dictionary &p_data);
  228. Dictionary _get_data() const;
  229. Error _load_from_buffer(const Vector<uint8_t> &p_array, ImageMemLoadFunc p_loader);
  230. _FORCE_INLINE_ void _generate_mipmap_from_format(Image::Format p_format, const uint8_t *p_src, uint8_t *p_dst, uint32_t p_width, uint32_t p_height, bool p_renormalize = false);
  231. static void average_4_uint8(uint8_t &p_out, const uint8_t &p_a, const uint8_t &p_b, const uint8_t &p_c, const uint8_t &p_d);
  232. static void average_4_float(float &p_out, const float &p_a, const float &p_b, const float &p_c, const float &p_d);
  233. static void average_4_half(uint16_t &p_out, const uint16_t &p_a, const uint16_t &p_b, const uint16_t &p_c, const uint16_t &p_d);
  234. static void average_4_rgbe9995(uint32_t &p_out, const uint32_t &p_a, const uint32_t &p_b, const uint32_t &p_c, const uint32_t &p_d);
  235. static void renormalize_uint8(uint8_t *p_rgb);
  236. static void renormalize_float(float *p_rgb);
  237. static void renormalize_half(uint16_t *p_rgb);
  238. static void renormalize_rgbe9995(uint32_t *p_rgb);
  239. public:
  240. int get_width() const;
  241. int get_height() const;
  242. Size2i get_size() const;
  243. bool has_mipmaps() const;
  244. int get_mipmap_count() const;
  245. // Convert the image to another format, conversion only to raw byte format.
  246. void convert(Format p_new_format);
  247. Format get_format() const;
  248. // Get where the mipmap begins in data.
  249. int64_t get_mipmap_offset(int p_mipmap) const;
  250. void get_mipmap_offset_and_size(int p_mipmap, int64_t &r_ofs, int64_t &r_size) const;
  251. void get_mipmap_offset_size_and_dimensions(int p_mipmap, int64_t &r_ofs, int64_t &r_size, int &w, int &h) const;
  252. static Image3DValidateError validate_3d_image(Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_images);
  253. static String get_3d_image_validation_error_text(Image3DValidateError p_error);
  254. // Resize the image, using the preferred interpolation method.
  255. void resize_to_po2(bool p_square = false, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
  256. void resize(int p_width, int p_height, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
  257. void shrink_x2();
  258. bool is_size_po2() const;
  259. // Crop the image to a specific size, if larger, then the image is filled by black.
  260. void crop_from_point(int p_x, int p_y, int p_width, int p_height);
  261. void crop(int p_width, int p_height);
  262. void rotate_90(ClockDirection p_direction);
  263. void rotate_180();
  264. void flip_x();
  265. void flip_y();
  266. // Generate a mipmap chain of an image (creates an image 1/4 the size, with averaging of 4->1).
  267. Error generate_mipmaps(bool p_renormalize = false);
  268. Error generate_mipmap_roughness(RoughnessChannel p_roughness_channel, const Ref<Image> &p_normal_map);
  269. void clear_mipmaps();
  270. void normalize();
  271. // Creates new internal image data of a given size and format. Current image will be lost.
  272. void initialize_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format);
  273. void initialize_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector<uint8_t> &p_data);
  274. void initialize_data(const char **p_xpm);
  275. // Returns true when the image is empty (0,0) in size.
  276. bool is_empty() const;
  277. Vector<uint8_t> get_data() const;
  278. Error load(const String &p_path);
  279. static Ref<Image> load_from_file(const String &p_path);
  280. Error save_png(const String &p_path) const;
  281. Error save_jpg(const String &p_path, float p_quality = 0.75) const;
  282. Error save_dds(const String &p_path) const;
  283. Vector<uint8_t> save_png_to_buffer() const;
  284. Vector<uint8_t> save_jpg_to_buffer(float p_quality = 0.75) const;
  285. Vector<uint8_t> save_exr_to_buffer(bool p_grayscale = false) const;
  286. Vector<uint8_t> save_dds_to_buffer() const;
  287. Error save_exr(const String &p_path, bool p_grayscale = false) const;
  288. Error save_webp(const String &p_path, const bool p_lossy = false, const float p_quality = 0.75f) const;
  289. Vector<uint8_t> save_webp_to_buffer(const bool p_lossy = false, const float p_quality = 0.75f) const;
  290. static Ref<Image> create_empty(int p_width, int p_height, bool p_use_mipmaps, Format p_format);
  291. static Ref<Image> create_from_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector<uint8_t> &p_data);
  292. void set_data(int p_width, int p_height, bool p_use_mipmaps, Format p_format, const Vector<uint8_t> &p_data);
  293. Image() = default; // Create an empty image.
  294. Image(int p_width, int p_height, bool p_use_mipmaps, Format p_format); // Create an empty image of a specific size and format.
  295. Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const Vector<uint8_t> &p_data); // Import an image of a specific size and format from a byte vector.
  296. Image(const uint8_t *p_mem_png_jpg, int p_len = -1); // Import either a png or jpg from a pointer.
  297. Image(const char **p_xpm); // Import an XPM image.
  298. ~Image() {}
  299. AlphaMode detect_alpha() const;
  300. bool is_invisible() const;
  301. static int get_format_pixel_size(Format p_format);
  302. static int get_format_pixel_rshift(Format p_format);
  303. static int get_format_block_size(Format p_format);
  304. static void get_format_min_pixel_size(Format p_format, int &r_w, int &r_h);
  305. static int64_t get_image_data_size(int p_width, int p_height, Format p_format, bool p_mipmaps = false);
  306. static int get_image_required_mipmaps(int p_width, int p_height, Format p_format);
  307. static Size2i get_image_mipmap_size(int p_width, int p_height, Format p_format, int p_mipmap);
  308. static int64_t get_image_mipmap_offset(int p_width, int p_height, Format p_format, int p_mipmap);
  309. static int64_t get_image_mipmap_offset_and_dimensions(int p_width, int p_height, Format p_format, int p_mipmap, int &r_w, int &r_h);
  310. Error compress(CompressMode p_mode, CompressSource p_source = COMPRESS_SOURCE_GENERIC, ASTCFormat p_astc_format = ASTC_FORMAT_4x4);
  311. Error compress_from_channels(CompressMode p_mode, UsedChannels p_channels, ASTCFormat p_astc_format = ASTC_FORMAT_4x4);
  312. Error decompress();
  313. bool is_compressed() const;
  314. static bool is_format_compressed(Format p_format);
  315. static bool can_decompress(const String &p_format_tag);
  316. void fix_alpha_edges();
  317. void premultiply_alpha();
  318. void srgb_to_linear();
  319. void linear_to_srgb();
  320. void normal_map_to_xy();
  321. Ref<Image> rgbe_to_srgb();
  322. Ref<Image> get_image_from_mipmap(int p_mipmap) const;
  323. void bump_map_to_normal_map(float bump_scale = 1.0);
  324. bool detect_signed(bool p_include_mips = true) const;
  325. void blit_rect(const Ref<Image> &p_src, const Rect2i &p_src_rect, const Point2i &p_dest);
  326. void blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2i &p_src_rect, const Point2i &p_dest);
  327. void blend_rect(const Ref<Image> &p_src, const Rect2i &p_src_rect, const Point2i &p_dest);
  328. void blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2i &p_src_rect, const Point2i &p_dest);
  329. void fill(const Color &p_color);
  330. void fill_rect(const Rect2i &p_rect, const Color &p_color);
  331. Rect2i get_used_rect() const;
  332. Ref<Image> get_region(const Rect2i &p_area) const;
  333. static String get_format_name(Format p_format);
  334. static uint32_t get_format_component_mask(Format p_format);
  335. Error load_png_from_buffer(const Vector<uint8_t> &p_array);
  336. Error load_jpg_from_buffer(const Vector<uint8_t> &p_array);
  337. Error load_webp_from_buffer(const Vector<uint8_t> &p_array);
  338. Error load_tga_from_buffer(const Vector<uint8_t> &p_array);
  339. Error load_bmp_from_buffer(const Vector<uint8_t> &p_array);
  340. Error load_ktx_from_buffer(const Vector<uint8_t> &p_array);
  341. Error load_dds_from_buffer(const Vector<uint8_t> &p_array);
  342. Error load_svg_from_buffer(const Vector<uint8_t> &p_array, float scale = 1.0);
  343. Error load_svg_from_string(const String &p_svg_str, float scale = 1.0);
  344. void convert_rg_to_ra_rgba8();
  345. void convert_ra_rgba8_to_rg();
  346. void convert_rgba8_to_bgra8();
  347. UsedChannels detect_used_channels(CompressSource p_source = COMPRESS_SOURCE_GENERIC) const;
  348. void optimize_channels();
  349. Color get_pixelv(const Point2i &p_point) const;
  350. Color get_pixel(int p_x, int p_y) const;
  351. void set_pixelv(const Point2i &p_point, const Color &p_color);
  352. void set_pixel(int p_x, int p_y, const Color &p_color);
  353. const uint8_t *ptr() const;
  354. uint8_t *ptrw();
  355. int64_t get_data_size() const;
  356. void adjust_bcs(float p_brightness, float p_contrast, float p_saturation);
  357. void set_as_black();
  358. void copy_internals_from(const Ref<Image> &p_image);
  359. Dictionary compute_image_metrics(const Ref<Image> p_compared_image, bool p_luma_metric = true);
  360. };
  361. VARIANT_ENUM_CAST(Image::Format)
  362. VARIANT_ENUM_CAST(Image::Interpolation)
  363. VARIANT_ENUM_CAST(Image::CompressMode)
  364. VARIANT_ENUM_CAST(Image::CompressSource)
  365. VARIANT_ENUM_CAST(Image::UsedChannels)
  366. VARIANT_ENUM_CAST(Image::AlphaMode)
  367. VARIANT_ENUM_CAST(Image::RoughnessChannel)
  368. VARIANT_ENUM_CAST(Image::ASTCFormat)