class_image.rst 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Image.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Image:
  5. Image
  6. =====
  7. **Inherits:** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Image datatype.
  12. Member Functions
  13. ----------------
  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>` dst **)** |
  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>` dst **)** |
  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>` dst **)** |
  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>` dst **)** |
  22. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`clear_mipmaps<class_Image_clear_mipmaps>` **(** **)** |
  24. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`int<class_int>` | :ref:`compress<class_Image_compress>` **(** :ref:`int<class_int>` mode, :ref:`int<class_int>` source, :ref:`float<class_float>` lossy_quality **)** |
  26. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`convert<class_Image_convert>` **(** :ref:`int<class_int>` format **)** |
  28. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`copy_from<class_Image_copy_from>` **(** :ref:`Image<class_image>` src **)** |
  30. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | 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 **)** |
  32. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | 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 **)** |
  34. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`crop<class_Image_crop>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height **)** |
  36. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`decompress<class_Image_decompress>` **(** **)** |
  38. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`detect_alpha<class_Image_detect_alpha>` **(** **)** const |
  40. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`expand_x2_hq2x<class_Image_expand_x2_hq2x>` **(** **)** |
  42. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`fill<class_Image_fill>` **(** :ref:`Color<class_color>` color **)** |
  44. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`fix_alpha_edges<class_Image_fix_alpha_edges>` **(** **)** |
  46. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`flip_x<class_Image_flip_x>` **(** **)** |
  48. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`flip_y<class_Image_flip_y>` **(** **)** |
  50. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`generate_mipmaps<class_Image_generate_mipmaps>` **(** **)** |
  52. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`PoolByteArray<class_poolbytearray>` | :ref:`get_data<class_Image_get_data>` **(** **)** const |
  54. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`get_format<class_Image_get_format>` **(** **)** const |
  56. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`get_height<class_Image_get_height>` **(** **)** const |
  58. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`int<class_int>` | :ref:`get_mipmap_offset<class_Image_get_mipmap_offset>` **(** :ref:`int<class_int>` mipmap **)** const |
  60. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`Color<class_color>` | :ref:`get_pixel<class_Image_get_pixel>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const |
  62. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Image<class_image>` | :ref:`get_rect<class_Image_get_rect>` **(** :ref:`Rect2<class_rect2>` rect **)** const |
  64. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Vector2<class_vector2>` | :ref:`get_size<class_Image_get_size>` **(** **)** const |
  66. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`Rect2<class_rect2>` | :ref:`get_used_rect<class_Image_get_used_rect>` **(** **)** const |
  68. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`int<class_int>` | :ref:`get_width<class_Image_get_width>` **(** **)** const |
  70. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`bool<class_bool>` | :ref:`has_mipmaps<class_Image_has_mipmaps>` **(** **)** const |
  72. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`is_compressed<class_Image_is_compressed>` **(** **)** const |
  74. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`is_empty<class_Image_is_empty>` **(** **)** const |
  76. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`bool<class_bool>` | :ref:`is_invisible<class_Image_is_invisible>` **(** **)** const |
  78. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`int<class_int>` | :ref:`load<class_Image_load>` **(** :ref:`String<class_string>` path **)** |
  80. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`lock<class_Image_lock>` **(** **)** |
  82. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`normalmap_to_xy<class_Image_normalmap_to_xy>` **(** **)** |
  84. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`premultiply_alpha<class_Image_premultiply_alpha>` **(** **)** |
  86. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`resize<class_Image_resize>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`int<class_int>` interpolation=1 **)** |
  88. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`resize_to_po2<class_Image_resize_to_po2>` **(** :ref:`bool<class_bool>` square=false **)** |
  90. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`int<class_int>` | :ref:`save_png<class_Image_save_png>` **(** :ref:`String<class_string>` path **)** const |
  92. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`set_pixel<class_Image_set_pixel>` **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`Color<class_color>` color **)** |
  94. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`shrink_x2<class_Image_shrink_x2>` **(** **)** |
  96. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`srgb_to_linear<class_Image_srgb_to_linear>` **(** **)** |
  98. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`unlock<class_Image_unlock>` **(** **)** |
  100. +--------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. Member Variables
  102. ----------------
  103. .. _class_Image_data:
  104. - :ref:`Dictionary<class_dictionary>` **data** - Holds all of the image's color data in a given format. See ``FORMAT\_\*`` constants.
  105. Numeric Constants
  106. -----------------
  107. - **FORMAT_L8** = **0**
  108. - **FORMAT_LA8** = **1**
  109. - **FORMAT_R8** = **2**
  110. - **FORMAT_RG8** = **3**
  111. - **FORMAT_RGB8** = **4**
  112. - **FORMAT_RGBA8** = **5**
  113. - **FORMAT_RGBA4444** = **6**
  114. - **FORMAT_RGBA5551** = **7**
  115. - **FORMAT_RF** = **8**
  116. - **FORMAT_RGF** = **9**
  117. - **FORMAT_RGBF** = **10**
  118. - **FORMAT_RGBAF** = **11**
  119. - **FORMAT_RH** = **12**
  120. - **FORMAT_RGH** = **13**
  121. - **FORMAT_RGBH** = **14**
  122. - **FORMAT_RGBAH** = **15**
  123. - **FORMAT_RGBE9995** = **16**
  124. - **FORMAT_DXT1** = **17**
  125. - **FORMAT_DXT3** = **18**
  126. - **FORMAT_DXT5** = **19**
  127. - **FORMAT_RGTC_R** = **20**
  128. - **FORMAT_RGTC_RG** = **21**
  129. - **FORMAT_BPTC_RGBA** = **22**
  130. - **FORMAT_BPTC_RGBF** = **23**
  131. - **FORMAT_BPTC_RGBFU** = **24**
  132. - **FORMAT_PVRTC2** = **25**
  133. - **FORMAT_PVRTC2A** = **26**
  134. - **FORMAT_PVRTC4** = **27**
  135. - **FORMAT_PVRTC4A** = **28**
  136. - **FORMAT_ETC** = **29**
  137. - **FORMAT_ETC2_R11** = **30**
  138. - **FORMAT_ETC2_R11S** = **31**
  139. - **FORMAT_ETC2_RG11** = **32**
  140. - **FORMAT_ETC2_RG11S** = **33**
  141. - **FORMAT_ETC2_RGB8** = **34**
  142. - **FORMAT_ETC2_RGBA8** = **35**
  143. - **FORMAT_ETC2_RGB8A1** = **36**
  144. - **FORMAT_MAX** = **37**
  145. - **INTERPOLATE_NEAREST** = **0**
  146. - **INTERPOLATE_BILINEAR** = **1**
  147. - **INTERPOLATE_CUBIC** = **2**
  148. - **ALPHA_NONE** = **0**
  149. - **ALPHA_BIT** = **1**
  150. - **ALPHA_BLEND** = **2**
  151. - **COMPRESS_S3TC** = **0**
  152. - **COMPRESS_PVRTC2** = **1**
  153. - **COMPRESS_PVRTC4** = **2**
  154. - **COMPRESS_ETC** = **3**
  155. - **COMPRESS_ETC2** = **4**
  156. - **COMPRESS_SOURCE_GENERIC** = **0**
  157. - **COMPRESS_SOURCE_SRGB** = **1**
  158. - **COMPRESS_SOURCE_NORMAL** = **2**
  159. Description
  160. -----------
  161. Native image datatype. Contains image data, which can be converted to a :ref:`Texture<class_texture>`, and several functions to interact with it. The maximum width and height for an ``Image`` is 16384 pixels.
  162. Member Function Description
  163. ---------------------------
  164. .. _class_Image_blend_rect:
  165. - void **blend_rect** **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)**
  166. Alpha-blends ``src_rect`` from ``src`` image to this image at coordinates ``dest``.
  167. .. _class_Image_blend_rect_mask:
  168. - 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 **)**
  169. Alpha-blends ``src_rect`` from ``src`` image to this image using ``mask`` image at coordinates ``dst``. Alpha channels are required for both ``src`` and ``mask``. ``dst`` pixels and ``src`` pixels will blend if the corresponding mask pixel's alpha value is not 0. ``src`` image and ``mask`` image **must** have the same size (width and height) but they can have different formats.
  170. .. _class_Image_blit_rect:
  171. - void **blit_rect** **(** :ref:`Image<class_image>` src, :ref:`Rect2<class_rect2>` src_rect, :ref:`Vector2<class_vector2>` dst **)**
  172. Copies ``src_rect`` from ``src`` image to this image at coordinates ``dst``.
  173. .. _class_Image_blit_rect_mask:
  174. - 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 **)**
  175. Blits ``src_rect`` area from ``src`` image to this image at the coordinates given by ``dst``. ``src`` pixel is copied onto ``dst`` if the corresponding ``mask`` pixel's alpha value is not 0. ``src`` image and ``mask`` image **must** have the same size (width and height) but they can have different formats.
  176. .. _class_Image_clear_mipmaps:
  177. - void **clear_mipmaps** **(** **)**
  178. Removes the image's mipmaps.
  179. .. _class_Image_compress:
  180. - :ref:`int<class_int>` **compress** **(** :ref:`int<class_int>` mode, :ref:`int<class_int>` source, :ref:`float<class_float>` lossy_quality **)**
  181. Compresses the image to use less memory. Can not directly access pixel data while the image is compressed. Returns error if the chosen compression mode is not available. See ``COMPRESS\_\*`` constants.
  182. .. _class_Image_convert:
  183. - void **convert** **(** :ref:`int<class_int>` format **)**
  184. Converts the image's format. See ``FORMAT\_\*`` constants.
  185. .. _class_Image_copy_from:
  186. - void **copy_from** **(** :ref:`Image<class_image>` src **)**
  187. Copies ``src`` image to this image.
  188. .. _class_Image_create:
  189. - void **create** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`bool<class_bool>` use_mipmaps, :ref:`int<class_int>` format **)**
  190. Creates an empty image of given size and format. See ``FORMAT\_\*`` constants. If ``use_mipmaps`` is true then generate mipmaps for this image. See the ``generate_mipmaps`` method.
  191. .. _class_Image_create_from_data:
  192. - 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 **)**
  193. Creates a new image of given size and format. See ``FORMAT\_\*`` constants. Fills the image with the given raw data. If ``use_mipmaps`` is true then generate mipmaps for this image. See the ``generate_mipmaps`` method.
  194. .. _class_Image_crop:
  195. - void **crop** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height **)**
  196. Crops the image to the given ``width`` and ``height``. If the specified size is larger than the current size, the extra area is filled with black pixels.
  197. .. _class_Image_decompress:
  198. - :ref:`int<class_int>` **decompress** **(** **)**
  199. Decompresses the image if it is compressed. Returns an error if decompress function is not available.
  200. .. _class_Image_detect_alpha:
  201. - :ref:`int<class_int>` **detect_alpha** **(** **)** const
  202. Returns ALPHA_BLEND if the image has data for alpha values. Returns ALPHA_BIT if all the alpha values are below a certain threshold or the maximum value. Returns ALPHA_NONE if no data for alpha values is found.
  203. .. _class_Image_expand_x2_hq2x:
  204. - void **expand_x2_hq2x** **(** **)**
  205. Stretches the image and enlarges it by a factor of 2. No interpolation is done.
  206. .. _class_Image_fill:
  207. - void **fill** **(** :ref:`Color<class_color>` color **)**
  208. Fills the image with a given :ref:`Color<class_color>`.
  209. .. _class_Image_fix_alpha_edges:
  210. - void **fix_alpha_edges** **(** **)**
  211. Blends low-alpha pixels with nearby pixels.
  212. .. _class_Image_flip_x:
  213. - void **flip_x** **(** **)**
  214. Flips the image horizontally.
  215. .. _class_Image_flip_y:
  216. - void **flip_y** **(** **)**
  217. Flips the image vertically.
  218. .. _class_Image_generate_mipmaps:
  219. - :ref:`int<class_int>` **generate_mipmaps** **(** **)**
  220. Generates mipmaps for the image. Mipmaps are pre-calculated and lower resolution copies of the image. Mipmaps are automatically used if the image needs to be scaled down when rendered. This improves image quality and the performance of the rendering. Returns an error if the image is compressed, in a custom format or if the image's width/height is 0.
  221. .. _class_Image_get_data:
  222. - :ref:`PoolByteArray<class_poolbytearray>` **get_data** **(** **)** const
  223. Returns the image's raw data.
  224. .. _class_Image_get_format:
  225. - :ref:`int<class_int>` **get_format** **(** **)** const
  226. Returns the image's raw data.
  227. .. _class_Image_get_height:
  228. - :ref:`int<class_int>` **get_height** **(** **)** const
  229. Returns the image's height.
  230. .. _class_Image_get_mipmap_offset:
  231. - :ref:`int<class_int>` **get_mipmap_offset** **(** :ref:`int<class_int>` mipmap **)** const
  232. Returns the offset where the image's mipmap with index ``mipmap`` is stored in the ``data`` dictionary.
  233. .. _class_Image_get_pixel:
  234. - :ref:`Color<class_color>` **get_pixel** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y **)** const
  235. Returns the color of the pixel at ``(x, y)`` if the image is locked. If the image is unlocked it always returns a :ref:`Color<class_color>` with the value ``(0, 0, 0, 1.0)``.
  236. .. _class_Image_get_rect:
  237. - :ref:`Image<class_image>` **get_rect** **(** :ref:`Rect2<class_rect2>` rect **)** const
  238. Returns a new image that is a copy of the image's area specified with ``rect``.
  239. .. _class_Image_get_size:
  240. - :ref:`Vector2<class_vector2>` **get_size** **(** **)** const
  241. Returns the image's size (width and height).
  242. .. _class_Image_get_used_rect:
  243. - :ref:`Rect2<class_rect2>` **get_used_rect** **(** **)** const
  244. Returns a :ref:`Rect2<class_rect2>` enclosing the visible portion of the image.
  245. .. _class_Image_get_width:
  246. - :ref:`int<class_int>` **get_width** **(** **)** const
  247. Returns the image's width.
  248. .. _class_Image_has_mipmaps:
  249. - :ref:`bool<class_bool>` **has_mipmaps** **(** **)** const
  250. Returns ``true`` if the image has generated mipmaps.
  251. .. _class_Image_is_compressed:
  252. - :ref:`bool<class_bool>` **is_compressed** **(** **)** const
  253. Returns ``true`` if the image is compressed.
  254. .. _class_Image_is_empty:
  255. - :ref:`bool<class_bool>` **is_empty** **(** **)** const
  256. Returns ``true`` if the image has no data.
  257. .. _class_Image_is_invisible:
  258. - :ref:`bool<class_bool>` **is_invisible** **(** **)** const
  259. Returns ``true`` if all the image's pixels have an alpha value of 0. Returns ``false`` if any pixel has an alpha value higher than 0.
  260. .. _class_Image_load:
  261. - :ref:`int<class_int>` **load** **(** :ref:`String<class_string>` path **)**
  262. Loads an image from file ``path``.
  263. .. _class_Image_lock:
  264. - void **lock** **(** **)**
  265. Locks the data and prevents changes.
  266. .. _class_Image_normalmap_to_xy:
  267. - void **normalmap_to_xy** **(** **)**
  268. Converts the image's data to represent coordinates on a 3D plane. This is used when the image represents a normalmap. A normalmap can add lots of detail to a 3D surface without increasing the polygon count.
  269. .. _class_Image_premultiply_alpha:
  270. - void **premultiply_alpha** **(** **)**
  271. Multiplies color values with alpha values. Resulting color values for a pixel are ``(color \* alpha)/256``.
  272. .. _class_Image_resize:
  273. - void **resize** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`int<class_int>` interpolation=1 **)**
  274. Resizes the image to the given ``width`` and ``height``. New pixels are calculated using ``interpolation``. See ``interpolation`` constants.
  275. .. _class_Image_resize_to_po2:
  276. - void **resize_to_po2** **(** :ref:`bool<class_bool>` square=false **)**
  277. Resizes the image to the nearest power of 2 for the width and height. If ``square`` is ``true`` then set width and height to be the same.
  278. .. _class_Image_save_png:
  279. - :ref:`int<class_int>` **save_png** **(** :ref:`String<class_string>` path **)** const
  280. Saves the image as a PNG file to ``path``.
  281. .. _class_Image_set_pixel:
  282. - void **set_pixel** **(** :ref:`int<class_int>` x, :ref:`int<class_int>` y, :ref:`Color<class_color>` color **)**
  283. Sets the :ref:`Color<class_color>` of the pixel at ``(x, y)`` if the image is unlocked. Example:
  284. ``
  285. var img = Image.new()
  286. img.lock()
  287. img.set_pixel(x, y, color) # Does not have an effect
  288. img.unlock()
  289. img.set_pixel(x, y, color) # Works
  290. ``.
  291. .. _class_Image_shrink_x2:
  292. - void **shrink_x2** **(** **)**
  293. Shrinks the image by a factor of 2.
  294. .. _class_Image_srgb_to_linear:
  295. - void **srgb_to_linear** **(** **)**
  296. Converts the raw data from the sRGB colorspace to a linear scale.
  297. .. _class_Image_unlock:
  298. - void **unlock** **(** **)**
  299. Unlocks the data for writing access.