class_image.rst 29 KB

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