class_image.rst 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Image:
  4. Image
  5. =====
  6. **Inherits:** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Image datatype.
  11. Member Functions
  12. ----------------
  13. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`blend_rect<class_Image_blend_rect>` **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)** |
  15. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`blend_rect_mask<class_Image_blend_rect_mask>` **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` mask, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)** |
  17. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`blit_rect<class_Image_blit_rect>` **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)** |
  19. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`blit_rect_mask<class_Image_blit_rect_mask>` **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` mask, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)** |
  21. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`clear_mipmaps<class_Image_clear_mipmaps>` **(** **)** |
  23. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`compress<class_Image_compress>` **(** :ref:`int<class_int>` mode, :ref:`int<class_int>` arg1, :ref:`float<class_float>` arg2 **)** |
  25. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`convert<class_Image_convert>` **(** :ref:`int<class_int>` format **)** |
  27. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`copy_from<class_Image_copy_from>` **(** :ref:`Image<class_image>` src **)** |
  29. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`create<class_Image_create>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`bool<class_bool>` use_mipmaps, :ref:`int<class_int>` format **)** |
  31. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`create_from_data<class_Image_create_from_data>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`bool<class_bool>` use_mipmaps, :ref:`int<class_int>` format, :ref:`PoolByteArray<class_poolbytearray>` data **)** |
  33. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`crop<class_Image_crop>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height **)** |
  35. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`decompress<class_Image_decompress>` **(** **)** |
  37. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`detect_alpha<class_Image_detect_alpha>` **(** **)** const |
  39. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`expand_x2_hq2x<class_Image_expand_x2_hq2x>` **(** **)** |
  41. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`fill<class_Image_fill>` **(** :ref:`Color<class_color>` color **)** |
  43. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`fix_alpha_edges<class_Image_fix_alpha_edges>` **(** **)** |
  45. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`flip_x<class_Image_flip_x>` **(** **)** |
  47. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`flip_y<class_Image_flip_y>` **(** **)** |
  49. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`int<class_int>` | :ref:`generate_mipmaps<class_Image_generate_mipmaps>` **(** **)** |
  51. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`PoolByteArray<class_poolbytearray>` | :ref:`get_data<class_Image_get_data>` **(** **)** const |
  53. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`int<class_int>` | :ref:`get_format<class_Image_get_format>` **(** **)** const |
  55. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`int<class_int>` | :ref:`get_height<class_Image_get_height>` **(** **)** const |
  57. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`int<class_int>` | :ref:`get_mipmap_offset<class_Image_get_mipmap_offset>` **(** :ref:`int<class_int>` mipmap **)** const |
  59. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Color<class_color>` | :ref:`get_pixel<class_Image_get_pixel>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  61. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Image<class_image>` | :ref:`get_rect<class_Image_get_rect>` **(** :ref:`Rect2<class_rect2>` rect **)** const |
  63. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Rect2<class_rect2>` | :ref:`get_used_rect<class_Image_get_used_rect>` **(** **)** const |
  65. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`int<class_int>` | :ref:`get_width<class_Image_get_width>` **(** **)** const |
  67. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`bool<class_bool>` | :ref:`has_mipmaps<class_Image_has_mipmaps>` **(** **)** const |
  69. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`bool<class_bool>` | :ref:`is_compressed<class_Image_is_compressed>` **(** **)** const |
  71. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`is_empty<class_Image_is_empty>` **(** **)** const |
  73. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`bool<class_bool>` | :ref:`is_invisible<class_Image_is_invisible>` **(** **)** const |
  75. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`int<class_int>` | :ref:`load<class_Image_load>` **(** :ref:`String<class_string>` path **)** |
  77. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`lock<class_Image_lock>` **(** **)** |
  79. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`normalmap_to_xy<class_Image_normalmap_to_xy>` **(** **)** |
  81. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | void | :ref:`premultiply_alpha<class_Image_premultiply_alpha>` **(** **)** |
  83. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | void | :ref:`resize<class_Image_resize>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`int<class_int>` interpolation=1 **)** |
  85. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | void | :ref:`resize_to_po2<class_Image_resize_to_po2>` **(** :ref:`bool<class_bool>` square=false **)** |
  87. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`int<class_int>` | :ref:`save_png<class_Image_save_png>` **(** :ref:`String<class_string>` path **)** const |
  89. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`set_pixel<class_Image_set_pixel>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`Color<class_color>` color **)** |
  91. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`shrink_x2<class_Image_shrink_x2>` **(** **)** |
  93. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | void | :ref:`srgb_to_linear<class_Image_srgb_to_linear>` **(** **)** |
  95. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | void | :ref:`unlock<class_Image_unlock>` **(** **)** |
  97. +--------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. Member Variables
  99. ----------------
  100. - :ref:`Dictionary<class_dictionary>` **data**
  101. Numeric Constants
  102. -----------------
  103. - **FORMAT_L8** = **0**
  104. - **FORMAT_LA8** = **1**
  105. - **FORMAT_R8** = **2**
  106. - **FORMAT_RG8** = **3**
  107. - **FORMAT_RGB8** = **4**
  108. - **FORMAT_RGBA8** = **5**
  109. - **FORMAT_RGBA4444** = **6**
  110. - **FORMAT_RGBA5551** = **7**
  111. - **FORMAT_RF** = **8**
  112. - **FORMAT_RGF** = **9**
  113. - **FORMAT_RGBF** = **10**
  114. - **FORMAT_RGBAF** = **11**
  115. - **FORMAT_RH** = **12**
  116. - **FORMAT_RGH** = **13**
  117. - **FORMAT_RGBH** = **14**
  118. - **FORMAT_RGBAH** = **15**
  119. - **FORMAT_RGBE9995** = **16**
  120. - **FORMAT_DXT1** = **17**
  121. - **FORMAT_DXT3** = **18**
  122. - **FORMAT_DXT5** = **19**
  123. - **FORMAT_RGTC_R** = **20**
  124. - **FORMAT_RGTC_RG** = **21**
  125. - **FORMAT_BPTC_RGBA** = **22**
  126. - **FORMAT_BPTC_RGBF** = **23**
  127. - **FORMAT_BPTC_RGBFU** = **24**
  128. - **FORMAT_PVRTC2** = **25**
  129. - **FORMAT_PVRTC2A** = **26**
  130. - **FORMAT_PVRTC4** = **27**
  131. - **FORMAT_PVRTC4A** = **28**
  132. - **FORMAT_ETC** = **29**
  133. - **FORMAT_ETC2_R11** = **30**
  134. - **FORMAT_ETC2_R11S** = **31**
  135. - **FORMAT_ETC2_RG11** = **32**
  136. - **FORMAT_ETC2_RG11S** = **33**
  137. - **FORMAT_ETC2_RGB8** = **34**
  138. - **FORMAT_ETC2_RGBA8** = **35**
  139. - **FORMAT_ETC2_RGB8A1** = **36**
  140. - **FORMAT_MAX** = **37**
  141. - **INTERPOLATE_NEAREST** = **0**
  142. - **INTERPOLATE_BILINEAR** = **1**
  143. - **INTERPOLATE_CUBIC** = **2**
  144. - **ALPHA_NONE** = **0**
  145. - **ALPHA_BIT** = **1**
  146. - **ALPHA_BLEND** = **2**
  147. - **COMPRESS_S3TC** = **0**
  148. - **COMPRESS_PVRTC2** = **1**
  149. - **COMPRESS_PVRTC4** = **2**
  150. - **COMPRESS_ETC** = **3**
  151. - **COMPRESS_ETC2** = **4**
  152. - **COMPRESS_SOURCE_GENERIC** = **0**
  153. - **COMPRESS_SOURCE_SRGB** = **1**
  154. - **COMPRESS_SOURCE_NORMAL** = **2**
  155. Description
  156. -----------
  157. Native image datatype. Contains image data, which can be converted to a texture, and several functions to interact with it.
  158. Member Function Description
  159. ---------------------------
  160. .. _class_Image_blend_rect:
  161. - void **blend_rect** **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)**
  162. Alpha-blends a "src_rect" :ref:`Rect2<class_rect2>` from "src" :ref:`Image<class_image>` to this :ref:`Image<class_image>` on coordinates "dest".
  163. .. _class_Image_blend_rect_mask:
  164. - void **blend_rect_mask** **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` mask, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)**
  165. Alpha-blends a "src_rect" :ref:`Rect2<class_rect2>` from "src" :ref:`Image<class_image>` to this :ref:`Image<class_image>` using a "mask" :ref:`Image<class_image>` on coordinates "dest". Alpha channels are required for both "src" and "mask", dest pixels and src pixels will blend if the corresponding mask pixel's alpha value is not 0. "src" :ref:`Image<class_image>` and "mask" :ref:`Image<class_image>` \*must\* have the same size (width and height) but they can have different formats
  166. .. _class_Image_blit_rect:
  167. - void **blit_rect** **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)**
  168. Copy a "src_rect" :ref:`Rect2<class_rect2>` from "src" :ref:`Image<class_image>` to this :ref:`Image<class_image>` on coordinates "dest".
  169. .. _class_Image_blit_rect_mask:
  170. - void **blit_rect_mask** **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` mask, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)**
  171. Blits a "src_rect" :ref:`Rect2<class_rect2>` from "src" :ref:`Image<class_image>` to this :ref:`Image<class_image>` using a "mask" :ref:`Image<class_image>` on coordinates "dest". Alpha channel is required for "mask", will copy src pixel onto dest if the corresponding mask pixel's alpha value is not 0. "src" :ref:`Image<class_image>` and "mask" :ref:`Image<class_image>` \*must\* have the same size (width and height) but they can have different formats
  172. .. _class_Image_clear_mipmaps:
  173. - void **clear_mipmaps** **(** **)**
  174. .. _class_Image_compress:
  175. - :ref:`int<class_int>` **compress** **(** :ref:`int<class_int>` mode, :ref:`int<class_int>` arg1, :ref:`float<class_float>` arg2 **)**
  176. .. _class_Image_convert:
  177. - void **convert** **(** :ref:`int<class_int>` format **)**
  178. .. _class_Image_copy_from:
  179. - void **copy_from** **(** :ref:`Image<class_image>` src **)**
  180. .. _class_Image_create:
  181. - void **create** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`bool<class_bool>` use_mipmaps, :ref:`int<class_int>` format **)**
  182. Create an empty image of a specific size and format.
  183. .. _class_Image_create_from_data:
  184. - void **create_from_data** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`bool<class_bool>` use_mipmaps, :ref:`int<class_int>` format, :ref:`PoolByteArray<class_poolbytearray>` data **)**
  185. .. _class_Image_crop:
  186. - void **crop** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height **)**
  187. .. _class_Image_decompress:
  188. - :ref:`int<class_int>` **decompress** **(** **)**
  189. .. _class_Image_detect_alpha:
  190. - :ref:`int<class_int>` **detect_alpha** **(** **)** const
  191. .. _class_Image_expand_x2_hq2x:
  192. - void **expand_x2_hq2x** **(** **)**
  193. .. _class_Image_fill:
  194. - void **fill** **(** :ref:`Color<class_color>` color **)**
  195. Fills an :ref:`Image<class_image>` with a specified :ref:`Color<class_color>`
  196. .. _class_Image_fix_alpha_edges:
  197. - void **fix_alpha_edges** **(** **)**
  198. .. _class_Image_flip_x:
  199. - void **flip_x** **(** **)**
  200. .. _class_Image_flip_y:
  201. - void **flip_y** **(** **)**
  202. .. _class_Image_generate_mipmaps:
  203. - :ref:`int<class_int>` **generate_mipmaps** **(** **)**
  204. .. _class_Image_get_data:
  205. - :ref:`PoolByteArray<class_poolbytearray>` **get_data** **(** **)** const
  206. Return the raw data of the :ref:`Image<class_image>`.
  207. .. _class_Image_get_format:
  208. - :ref:`int<class_int>` **get_format** **(** **)** const
  209. Return the format of the :ref:`Image<class_image>`, one of :ref:`Image<class_image>`.FORMAT\_\*.
  210. .. _class_Image_get_height:
  211. - :ref:`int<class_int>` **get_height** **(** **)** const
  212. Return the height of the :ref:`Image<class_image>`.
  213. .. _class_Image_get_mipmap_offset:
  214. - :ref:`int<class_int>` **get_mipmap_offset** **(** :ref:`int<class_int>` mipmap **)** const
  215. .. _class_Image_get_pixel:
  216. - :ref:`Color<class_color>` **get_pixel** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  217. .. _class_Image_get_rect:
  218. - :ref:`Image<class_image>` **get_rect** **(** :ref:`Rect2<class_rect2>` rect **)** const
  219. Return a new :ref:`Image<class_image>` that is a copy of "area" in this :ref:`Image<class_image>`.
  220. .. _class_Image_get_used_rect:
  221. - :ref:`Rect2<class_rect2>` **get_used_rect** **(** **)** const
  222. Return the area of this :ref:`Image<class_image>` that is used/visibly colored/opaque.
  223. .. _class_Image_get_width:
  224. - :ref:`int<class_int>` **get_width** **(** **)** const
  225. Return the width of the :ref:`Image<class_image>`.
  226. .. _class_Image_has_mipmaps:
  227. - :ref:`bool<class_bool>` **has_mipmaps** **(** **)** const
  228. .. _class_Image_is_compressed:
  229. - :ref:`bool<class_bool>` **is_compressed** **(** **)** const
  230. .. _class_Image_is_empty:
  231. - :ref:`bool<class_bool>` **is_empty** **(** **)** const
  232. .. _class_Image_is_invisible:
  233. - :ref:`bool<class_bool>` **is_invisible** **(** **)** const
  234. .. _class_Image_load:
  235. - :ref:`int<class_int>` **load** **(** :ref:`String<class_string>` path **)**
  236. Load an :ref:`Image<class_image>`.
  237. .. _class_Image_lock:
  238. - void **lock** **(** **)**
  239. .. _class_Image_normalmap_to_xy:
  240. - void **normalmap_to_xy** **(** **)**
  241. .. _class_Image_premultiply_alpha:
  242. - void **premultiply_alpha** **(** **)**
  243. .. _class_Image_resize:
  244. - void **resize** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`int<class_int>` interpolation=1 **)**
  245. .. _class_Image_resize_to_po2:
  246. - void **resize_to_po2** **(** :ref:`bool<class_bool>` square=false **)**
  247. .. _class_Image_save_png:
  248. - :ref:`int<class_int>` **save_png** **(** :ref:`String<class_string>` path **)** const
  249. Save this :ref:`Image<class_image>` as a png.
  250. .. _class_Image_set_pixel:
  251. - void **set_pixel** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`Color<class_color>` color **)**
  252. .. _class_Image_shrink_x2:
  253. - void **shrink_x2** **(** **)**
  254. .. _class_Image_srgb_to_linear:
  255. - void **srgb_to_linear** **(** **)**
  256. .. _class_Image_unlock:
  257. - void **unlock** **(** **)**