class_image.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. **Category:** Built-In Types
  7. Brief Description
  8. -----------------
  9. Image datatype.
  10. Member Functions
  11. ----------------
  12. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  13. | :ref:`Image<class_image>` | :ref:`Image<class_Image_Image>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`bool<class_bool>` mipmaps, :ref:`int<class_int>` format **)** |
  14. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`blend_rect<class_Image_blend_rect>` **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dest=0 **)** |
  16. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | 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>` dest=0 **)** |
  18. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`blit_rect<class_Image_blit_rect>` **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dest=0 **)** |
  20. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | 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>` dest=0 **)** |
  22. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`brush_transfer<class_Image_brush_transfer>` **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` brush, :ref:`Vector2<class_vector2>` pos=0 **)** |
  24. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Image<class_image>` | :ref:`brushed<class_Image_brushed>` **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` brush, :ref:`Vector2<class_vector2>` pos=0 **)** |
  26. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Image<class_image>` | :ref:`compressed<class_Image_compressed>` **(** :ref:`int<class_int>` format=0 **)** |
  28. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`Image<class_image>` | :ref:`converted<class_Image_converted>` **(** :ref:`int<class_int>` format=0 **)** |
  30. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Image<class_image>` | :ref:`decompressed<class_Image_decompressed>` **(** **)** |
  32. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`empty<class_Image_empty>` **(** **)** |
  34. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`fill<class_Image_fill>` **(** :ref:`Color<class_color>` color=0 **)** |
  36. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`fix_alpha_edges<class_Image_fix_alpha_edges>` **(** **)** |
  38. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`RawArray<class_rawarray>` | :ref:`get_data<class_Image_get_data>` **(** **)** |
  40. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`get_format<class_Image_get_format>` **(** **)** |
  42. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`get_height<class_Image_get_height>` **(** **)** |
  44. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Color<class_color>` | :ref:`get_pixel<class_Image_get_pixel>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` mipmap_level=0 **)** |
  46. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Image<class_image>` | :ref:`get_rect<class_Image_get_rect>` **(** :ref:`Rect2<class_rect2>` area=0 **)** |
  48. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Rect2<class_rect2>` | :ref:`get_used_rect<class_Image_get_used_rect>` **(** **)** |
  50. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`get_width<class_Image_get_width>` **(** **)** |
  52. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`load<class_Image_load>` **(** :ref:`String<class_string>` path=0 **)** |
  54. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`put_pixel<class_Image_put_pixel>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`Color<class_color>` color, :ref:`int<class_int>` mipmap_level=0 **)** |
  56. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Image<class_image>` | :ref:`resized<class_Image_resized>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` interpolation=1 **)** |
  58. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`int<class_int>` | :ref:`save_png<class_Image_save_png>` **(** :ref:`String<class_string>` path=0 **)** |
  60. +----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. Numeric Constants
  62. -----------------
  63. - **COMPRESS_BC** = **0**
  64. - **COMPRESS_PVRTC2** = **1**
  65. - **COMPRESS_PVRTC4** = **2**
  66. - **COMPRESS_ETC** = **3**
  67. - **FORMAT_GRAYSCALE** = **0**
  68. - **FORMAT_INTENSITY** = **1**
  69. - **FORMAT_GRAYSCALE_ALPHA** = **2**
  70. - **FORMAT_RGB** = **3**
  71. - **FORMAT_RGBA** = **4**
  72. - **FORMAT_INDEXED** = **5**
  73. - **FORMAT_INDEXED_ALPHA** = **6**
  74. - **FORMAT_YUV_422** = **7**
  75. - **FORMAT_YUV_444** = **8**
  76. - **FORMAT_BC1** = **9**
  77. - **FORMAT_BC2** = **10**
  78. - **FORMAT_BC3** = **11**
  79. - **FORMAT_BC4** = **12**
  80. - **FORMAT_BC5** = **13**
  81. - **FORMAT_PVRTC2** = **14**
  82. - **FORMAT_PVRTC2_ALPHA** = **15**
  83. - **FORMAT_PVRTC4** = **16**
  84. - **FORMAT_PVRTC4_ALPHA** = **17**
  85. - **FORMAT_ETC** = **18**
  86. - **FORMAT_ATC** = **19**
  87. - **FORMAT_ATC_ALPHA_EXPLICIT** = **20**
  88. - **FORMAT_ATC_ALPHA_INTERPOLATED** = **21**
  89. - **FORMAT_CUSTOM** = **22**
  90. - **INTERPOLATE_NEAREST** = **0**
  91. - **INTERPOLATE_BILINEAR** = **1**
  92. - **INTERPOLATE_CUBIC** = **2**
  93. Description
  94. -----------
  95. Built in native image datatype. Contains image data, which can be converted to a texture, and several functions to interact with it.
  96. Member Function Description
  97. ---------------------------
  98. .. _class_Image_Image:
  99. - :ref:`Image<class_image>` **Image** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`bool<class_bool>` mipmaps, :ref:`int<class_int>` format **)**
  100. Create an empty image of a specific size and format.
  101. .. _class_Image_blend_rect:
  102. - void **blend_rect** **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dest=0 **)**
  103. Alpha-blends a "src_rect" :ref:`Rect2<class_rect2>` from "src" :ref:`Image<class_image>` to this :ref:`Image<class_image>` on coordinates "dest".
  104. .. _class_Image_blend_rect_mask:
  105. - void **blend_rect_mask** **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` mask, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dest=0 **)**
  106. 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
  107. .. _class_Image_blit_rect:
  108. - void **blit_rect** **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dest=0 **)**
  109. Copy a "src_rect" :ref:`Rect2<class_rect2>` from "src" :ref:`Image<class_image>` to this :ref:`Image<class_image>` on coordinates "dest".
  110. .. _class_Image_blit_rect_mask:
  111. - void **blit_rect_mask** **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` mask, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dest=0 **)**
  112. 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
  113. .. _class_Image_brush_transfer:
  114. - void **brush_transfer** **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` brush, :ref:`Vector2<class_vector2>` pos=0 **)**
  115. Transfer data from "src" to this :ref:`Image<class_image>` using a "brush" as a mask/brush on coordinates "pos".
  116. .. _class_Image_brushed:
  117. - :ref:`Image<class_image>` **brushed** **(** :ref:`Image<class_image>` src, :ref:`Image<class_image>` brush, :ref:`Vector2<class_vector2>` pos=0 **)**
  118. Return a new :ref:`Image<class_image>` from this :ref:`Image<class_image>` that is created by brushhing see :ref:`brush_transfer<class_Image_brush_transfer>`.
  119. .. _class_Image_compressed:
  120. - :ref:`Image<class_image>` **compressed** **(** :ref:`int<class_int>` format=0 **)**
  121. Return a new compressed :ref:`Image<class_image>` from this :ref:`Image<class_image>` using one of :ref:`Image<class_image>`.COMPRESS\_\*.
  122. .. _class_Image_converted:
  123. - :ref:`Image<class_image>` **converted** **(** :ref:`int<class_int>` format=0 **)**
  124. Return a new :ref:`Image<class_image>` from this :ref:`Image<class_image>` with a different format.
  125. .. _class_Image_decompressed:
  126. - :ref:`Image<class_image>` **decompressed** **(** **)**
  127. Return a new decompressed :ref:`Image<class_image>`.
  128. .. _class_Image_empty:
  129. - :ref:`bool<class_bool>` **empty** **(** **)**
  130. Return whether this :ref:`Image<class_image>` is empty(no data).
  131. .. _class_Image_fill:
  132. - void **fill** **(** :ref:`Color<class_color>` color=0 **)**
  133. Fills an :ref:`Image<class_image>` with a specified :ref:`Color<class_color>`
  134. .. _class_Image_fix_alpha_edges:
  135. - void **fix_alpha_edges** **(** **)**
  136. .. _class_Image_get_data:
  137. - :ref:`RawArray<class_rawarray>` **get_data** **(** **)**
  138. Return the raw data of the :ref:`Image<class_image>`.
  139. .. _class_Image_get_format:
  140. - :ref:`int<class_int>` **get_format** **(** **)**
  141. Return the format of the :ref:`Image<class_image>`, one of :ref:`Image<class_image>`.FORMAT\_\*.
  142. .. _class_Image_get_height:
  143. - :ref:`int<class_int>` **get_height** **(** **)**
  144. Return the height of the :ref:`Image<class_image>`.
  145. .. _class_Image_get_pixel:
  146. - :ref:`Color<class_color>` **get_pixel** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` mipmap_level=0 **)**
  147. Return the color of the pixel in the :ref:`Image<class_image>` on coordinates "x,y" on mipmap level "mipmap_level".
  148. .. _class_Image_get_rect:
  149. - :ref:`Image<class_image>` **get_rect** **(** :ref:`Rect2<class_rect2>` area=0 **)**
  150. Return a new :ref:`Image<class_image>` that is a copy of "area" in this :ref:`Image<class_image>`.
  151. .. _class_Image_get_used_rect:
  152. - :ref:`Rect2<class_rect2>` **get_used_rect** **(** **)**
  153. Return the area of this :ref:`Image<class_image>` that is used/visibly colored/opaque.
  154. .. _class_Image_get_width:
  155. - :ref:`int<class_int>` **get_width** **(** **)**
  156. Return the width of the :ref:`Image<class_image>`.
  157. .. _class_Image_load:
  158. - :ref:`int<class_int>` **load** **(** :ref:`String<class_string>` path=0 **)**
  159. Load an :ref:`Image<class_image>`.
  160. .. _class_Image_put_pixel:
  161. - void **put_pixel** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`Color<class_color>` color, :ref:`int<class_int>` mipmap_level=0 **)**
  162. Put a pixel of "color" on coordinates "x,y" on mipmap level "mipmap_level".
  163. .. _class_Image_resized:
  164. - :ref:`Image<class_image>` **resized** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`int<class_int>` interpolation=1 **)**
  165. Return a new :ref:`Image<class_image>` from this :ref:`Image<class_image>` that is resized to size "x,y" using :ref:`Image<class_image>`.INTERPOLATE\_\*.
  166. .. _class_Image_save_png:
  167. - :ref:`int<class_int>` **save_png** **(** :ref:`String<class_string>` path=0 **)**
  168. Save this :ref:`Image<class_image>` as a png.