class_image.rst 107 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Image.xml.
  6. .. _class_Image:
  7. Image
  8. =====
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Image datatype.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Native image datatype. Contains image data which can be converted to an :ref:`ImageTexture<class_ImageTexture>` and provides commonly used *image processing* methods. The maximum width and height for an **Image** are :ref:`MAX_WIDTH<class_Image_constant_MAX_WIDTH>` and :ref:`MAX_HEIGHT<class_Image_constant_MAX_HEIGHT>`.
  15. An **Image** cannot be assigned to a texture property of an object directly (such as :ref:`Sprite2D.texture<class_Sprite2D_property_texture>`), and has to be converted manually to an :ref:`ImageTexture<class_ImageTexture>` first.
  16. \ **Note:** The maximum image size is 16384ร—16384 pixels due to graphics hardware limitations. Larger images may fail to import.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`Importing images <../tutorials/assets_pipeline/importing_images>`
  21. - :doc:`Runtime file loading and saving <../tutorials/io/runtime_file_loading_and_saving>`
  22. .. rst-class:: classref-reftable-group
  23. Properties
  24. ----------
  25. .. table::
  26. :widths: auto
  27. +-------------------------------------+----------------------------------------+------------------------------------------------------------------------------------------------+
  28. | :ref:`Dictionary<class_Dictionary>` | :ref:`data<class_Image_property_data>` | ``{ "data": PackedByteArray(), "format": "Lum8", "height": 0, "mipmaps": false, "width": 0 }`` |
  29. +-------------------------------------+----------------------------------------+------------------------------------------------------------------------------------------------+
  30. .. rst-class:: classref-reftable-group
  31. Methods
  32. -------
  33. .. table::
  34. :widths: auto
  35. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | |void| | :ref:`adjust_bcs<class_Image_method_adjust_bcs>`\ (\ brightness\: :ref:`float<class_float>`, contrast\: :ref:`float<class_float>`, saturation\: :ref:`float<class_float>`\ ) |
  37. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | |void| | :ref:`blend_rect<class_Image_method_blend_rect>`\ (\ src\: :ref:`Image<class_Image>`, src_rect\: :ref:`Rect2i<class_Rect2i>`, dst\: :ref:`Vector2i<class_Vector2i>`\ ) |
  39. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | |void| | :ref:`blend_rect_mask<class_Image_method_blend_rect_mask>`\ (\ src\: :ref:`Image<class_Image>`, mask\: :ref:`Image<class_Image>`, src_rect\: :ref:`Rect2i<class_Rect2i>`, dst\: :ref:`Vector2i<class_Vector2i>`\ ) |
  41. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | |void| | :ref:`blit_rect<class_Image_method_blit_rect>`\ (\ src\: :ref:`Image<class_Image>`, src_rect\: :ref:`Rect2i<class_Rect2i>`, dst\: :ref:`Vector2i<class_Vector2i>`\ ) |
  43. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | |void| | :ref:`blit_rect_mask<class_Image_method_blit_rect_mask>`\ (\ src\: :ref:`Image<class_Image>`, mask\: :ref:`Image<class_Image>`, src_rect\: :ref:`Rect2i<class_Rect2i>`, dst\: :ref:`Vector2i<class_Vector2i>`\ ) |
  45. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | |void| | :ref:`bump_map_to_normal_map<class_Image_method_bump_map_to_normal_map>`\ (\ bump_scale\: :ref:`float<class_float>` = 1.0\ ) |
  47. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | |void| | :ref:`clear_mipmaps<class_Image_method_clear_mipmaps>`\ (\ ) |
  49. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`compress<class_Image_method_compress>`\ (\ mode\: :ref:`CompressMode<enum_Image_CompressMode>`, source\: :ref:`CompressSource<enum_Image_CompressSource>` = 0, astc_format\: :ref:`ASTCFormat<enum_Image_ASTCFormat>` = 0\ ) |
  51. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`compress_from_channels<class_Image_method_compress_from_channels>`\ (\ mode\: :ref:`CompressMode<enum_Image_CompressMode>`, channels\: :ref:`UsedChannels<enum_Image_UsedChannels>`, astc_format\: :ref:`ASTCFormat<enum_Image_ASTCFormat>` = 0\ ) |
  53. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Dictionary<class_Dictionary>` | :ref:`compute_image_metrics<class_Image_method_compute_image_metrics>`\ (\ compared_image\: :ref:`Image<class_Image>`, use_luma\: :ref:`bool<class_bool>`\ ) |
  55. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | |void| | :ref:`convert<class_Image_method_convert>`\ (\ format\: :ref:`Format<enum_Image_Format>`\ ) |
  57. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | |void| | :ref:`copy_from<class_Image_method_copy_from>`\ (\ src\: :ref:`Image<class_Image>`\ ) |
  59. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Image<class_Image>` | :ref:`create<class_Image_method_create>`\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, use_mipmaps\: :ref:`bool<class_bool>`, format\: :ref:`Format<enum_Image_Format>`\ ) |static| |
  61. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Image<class_Image>` | :ref:`create_empty<class_Image_method_create_empty>`\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, use_mipmaps\: :ref:`bool<class_bool>`, format\: :ref:`Format<enum_Image_Format>`\ ) |static| |
  63. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Image<class_Image>` | :ref:`create_from_data<class_Image_method_create_from_data>`\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, use_mipmaps\: :ref:`bool<class_bool>`, format\: :ref:`Format<enum_Image_Format>`, data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |static| |
  65. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | |void| | :ref:`crop<class_Image_method_crop>`\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`\ ) |
  67. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`decompress<class_Image_method_decompress>`\ (\ ) |
  69. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`AlphaMode<enum_Image_AlphaMode>` | :ref:`detect_alpha<class_Image_method_detect_alpha>`\ (\ ) |const| |
  71. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`UsedChannels<enum_Image_UsedChannels>` | :ref:`detect_used_channels<class_Image_method_detect_used_channels>`\ (\ source\: :ref:`CompressSource<enum_Image_CompressSource>` = 0\ ) |const| |
  73. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | |void| | :ref:`fill<class_Image_method_fill>`\ (\ color\: :ref:`Color<class_Color>`\ ) |
  75. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | |void| | :ref:`fill_rect<class_Image_method_fill_rect>`\ (\ rect\: :ref:`Rect2i<class_Rect2i>`, color\: :ref:`Color<class_Color>`\ ) |
  77. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | |void| | :ref:`fix_alpha_edges<class_Image_method_fix_alpha_edges>`\ (\ ) |
  79. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | |void| | :ref:`flip_x<class_Image_method_flip_x>`\ (\ ) |
  81. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | |void| | :ref:`flip_y<class_Image_method_flip_y>`\ (\ ) |
  83. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`generate_mipmaps<class_Image_method_generate_mipmaps>`\ (\ renormalize\: :ref:`bool<class_bool>` = false\ ) |
  85. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`get_data<class_Image_method_get_data>`\ (\ ) |const| |
  87. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`int<class_int>` | :ref:`get_data_size<class_Image_method_get_data_size>`\ (\ ) |const| |
  89. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`Format<enum_Image_Format>` | :ref:`get_format<class_Image_method_get_format>`\ (\ ) |const| |
  91. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`int<class_int>` | :ref:`get_height<class_Image_method_get_height>`\ (\ ) |const| |
  93. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`int<class_int>` | :ref:`get_mipmap_count<class_Image_method_get_mipmap_count>`\ (\ ) |const| |
  95. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`int<class_int>` | :ref:`get_mipmap_offset<class_Image_method_get_mipmap_offset>`\ (\ mipmap\: :ref:`int<class_int>`\ ) |const| |
  97. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`Color<class_Color>` | :ref:`get_pixel<class_Image_method_get_pixel>`\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`\ ) |const| |
  99. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`Color<class_Color>` | :ref:`get_pixelv<class_Image_method_get_pixelv>`\ (\ point\: :ref:`Vector2i<class_Vector2i>`\ ) |const| |
  101. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`Image<class_Image>` | :ref:`get_region<class_Image_method_get_region>`\ (\ region\: :ref:`Rect2i<class_Rect2i>`\ ) |const| |
  103. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_size<class_Image_method_get_size>`\ (\ ) |const| |
  105. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`Rect2i<class_Rect2i>` | :ref:`get_used_rect<class_Image_method_get_used_rect>`\ (\ ) |const| |
  107. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`int<class_int>` | :ref:`get_width<class_Image_method_get_width>`\ (\ ) |const| |
  109. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`bool<class_bool>` | :ref:`has_mipmaps<class_Image_method_has_mipmaps>`\ (\ ) |const| |
  111. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`bool<class_bool>` | :ref:`is_compressed<class_Image_method_is_compressed>`\ (\ ) |const| |
  113. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`bool<class_bool>` | :ref:`is_empty<class_Image_method_is_empty>`\ (\ ) |const| |
  115. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`bool<class_bool>` | :ref:`is_invisible<class_Image_method_is_invisible>`\ (\ ) |const| |
  117. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | |void| | :ref:`linear_to_srgb<class_Image_method_linear_to_srgb>`\ (\ ) |
  119. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load<class_Image_method_load>`\ (\ path\: :ref:`String<class_String>`\ ) |
  121. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_bmp_from_buffer<class_Image_method_load_bmp_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  123. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`Image<class_Image>` | :ref:`load_from_file<class_Image_method_load_from_file>`\ (\ path\: :ref:`String<class_String>`\ ) |static| |
  125. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_jpg_from_buffer<class_Image_method_load_jpg_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  127. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_ktx_from_buffer<class_Image_method_load_ktx_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  129. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_png_from_buffer<class_Image_method_load_png_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  131. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_svg_from_buffer<class_Image_method_load_svg_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`, scale\: :ref:`float<class_float>` = 1.0\ ) |
  133. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_svg_from_string<class_Image_method_load_svg_from_string>`\ (\ svg_str\: :ref:`String<class_String>`, scale\: :ref:`float<class_float>` = 1.0\ ) |
  135. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_tga_from_buffer<class_Image_method_load_tga_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  137. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_webp_from_buffer<class_Image_method_load_webp_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  139. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | |void| | :ref:`normal_map_to_xy<class_Image_method_normal_map_to_xy>`\ (\ ) |
  141. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | |void| | :ref:`premultiply_alpha<class_Image_method_premultiply_alpha>`\ (\ ) |
  143. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | |void| | :ref:`resize<class_Image_method_resize>`\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, interpolation\: :ref:`Interpolation<enum_Image_Interpolation>` = 1\ ) |
  145. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | |void| | :ref:`resize_to_po2<class_Image_method_resize_to_po2>`\ (\ square\: :ref:`bool<class_bool>` = false, interpolation\: :ref:`Interpolation<enum_Image_Interpolation>` = 1\ ) |
  147. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | :ref:`Image<class_Image>` | :ref:`rgbe_to_srgb<class_Image_method_rgbe_to_srgb>`\ (\ ) |
  149. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | |void| | :ref:`rotate_90<class_Image_method_rotate_90>`\ (\ direction\: :ref:`ClockDirection<enum_@GlobalScope_ClockDirection>`\ ) |
  151. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | |void| | :ref:`rotate_180<class_Image_method_rotate_180>`\ (\ ) |
  153. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save_exr<class_Image_method_save_exr>`\ (\ path\: :ref:`String<class_String>`, grayscale\: :ref:`bool<class_bool>` = false\ ) |const| |
  155. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  156. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`save_exr_to_buffer<class_Image_method_save_exr_to_buffer>`\ (\ grayscale\: :ref:`bool<class_bool>` = false\ ) |const| |
  157. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  158. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save_jpg<class_Image_method_save_jpg>`\ (\ path\: :ref:`String<class_String>`, quality\: :ref:`float<class_float>` = 0.75\ ) |const| |
  159. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  160. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`save_jpg_to_buffer<class_Image_method_save_jpg_to_buffer>`\ (\ quality\: :ref:`float<class_float>` = 0.75\ ) |const| |
  161. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  162. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save_png<class_Image_method_save_png>`\ (\ path\: :ref:`String<class_String>`\ ) |const| |
  163. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  164. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`save_png_to_buffer<class_Image_method_save_png_to_buffer>`\ (\ ) |const| |
  165. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  166. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save_webp<class_Image_method_save_webp>`\ (\ path\: :ref:`String<class_String>`, lossy\: :ref:`bool<class_bool>` = false, quality\: :ref:`float<class_float>` = 0.75\ ) |const| |
  167. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  168. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`save_webp_to_buffer<class_Image_method_save_webp_to_buffer>`\ (\ lossy\: :ref:`bool<class_bool>` = false, quality\: :ref:`float<class_float>` = 0.75\ ) |const| |
  169. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  170. | |void| | :ref:`set_data<class_Image_method_set_data>`\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, use_mipmaps\: :ref:`bool<class_bool>`, format\: :ref:`Format<enum_Image_Format>`, data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  171. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  172. | |void| | :ref:`set_pixel<class_Image_method_set_pixel>`\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`, color\: :ref:`Color<class_Color>`\ ) |
  173. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  174. | |void| | :ref:`set_pixelv<class_Image_method_set_pixelv>`\ (\ point\: :ref:`Vector2i<class_Vector2i>`, color\: :ref:`Color<class_Color>`\ ) |
  175. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  176. | |void| | :ref:`shrink_x2<class_Image_method_shrink_x2>`\ (\ ) |
  177. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  178. | |void| | :ref:`srgb_to_linear<class_Image_method_srgb_to_linear>`\ (\ ) |
  179. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  180. .. rst-class:: classref-section-separator
  181. ----
  182. .. rst-class:: classref-descriptions-group
  183. Enumerations
  184. ------------
  185. .. _enum_Image_Format:
  186. .. rst-class:: classref-enumeration
  187. enum **Format**: :ref:`๐Ÿ”—<enum_Image_Format>`
  188. .. _class_Image_constant_FORMAT_L8:
  189. .. rst-class:: classref-enumeration-constant
  190. :ref:`Format<enum_Image_Format>` **FORMAT_L8** = ``0``
  191. Texture format with a single 8-bit depth representing luminance.
  192. .. _class_Image_constant_FORMAT_LA8:
  193. .. rst-class:: classref-enumeration-constant
  194. :ref:`Format<enum_Image_Format>` **FORMAT_LA8** = ``1``
  195. OpenGL texture format with two values, luminance and alpha each stored with 8 bits.
  196. .. _class_Image_constant_FORMAT_R8:
  197. .. rst-class:: classref-enumeration-constant
  198. :ref:`Format<enum_Image_Format>` **FORMAT_R8** = ``2``
  199. OpenGL texture format ``RED`` with a single component and a bitdepth of 8.
  200. .. _class_Image_constant_FORMAT_RG8:
  201. .. rst-class:: classref-enumeration-constant
  202. :ref:`Format<enum_Image_Format>` **FORMAT_RG8** = ``3``
  203. OpenGL texture format ``RG`` with two components and a bitdepth of 8 for each.
  204. .. _class_Image_constant_FORMAT_RGB8:
  205. .. rst-class:: classref-enumeration-constant
  206. :ref:`Format<enum_Image_Format>` **FORMAT_RGB8** = ``4``
  207. OpenGL texture format ``RGB`` with three components, each with a bitdepth of 8.
  208. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, an sRGB to linear color space conversion is performed.
  209. .. _class_Image_constant_FORMAT_RGBA8:
  210. .. rst-class:: classref-enumeration-constant
  211. :ref:`Format<enum_Image_Format>` **FORMAT_RGBA8** = ``5``
  212. OpenGL texture format ``RGBA`` with four components, each with a bitdepth of 8.
  213. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, an sRGB to linear color space conversion is performed.
  214. .. _class_Image_constant_FORMAT_RGBA4444:
  215. .. rst-class:: classref-enumeration-constant
  216. :ref:`Format<enum_Image_Format>` **FORMAT_RGBA4444** = ``6``
  217. OpenGL texture format ``RGBA`` with four components, each with a bitdepth of 4.
  218. .. _class_Image_constant_FORMAT_RGB565:
  219. .. rst-class:: classref-enumeration-constant
  220. :ref:`Format<enum_Image_Format>` **FORMAT_RGB565** = ``7``
  221. OpenGL texture format ``RGB`` with three components. Red and blue have a bitdepth of 5, and green has a bitdepth of 6.
  222. .. _class_Image_constant_FORMAT_RF:
  223. .. rst-class:: classref-enumeration-constant
  224. :ref:`Format<enum_Image_Format>` **FORMAT_RF** = ``8``
  225. OpenGL texture format ``GL_R32F`` where there's one component, a 32-bit floating-point value.
  226. .. _class_Image_constant_FORMAT_RGF:
  227. .. rst-class:: classref-enumeration-constant
  228. :ref:`Format<enum_Image_Format>` **FORMAT_RGF** = ``9``
  229. OpenGL texture format ``GL_RG32F`` where there are two components, each a 32-bit floating-point values.
  230. .. _class_Image_constant_FORMAT_RGBF:
  231. .. rst-class:: classref-enumeration-constant
  232. :ref:`Format<enum_Image_Format>` **FORMAT_RGBF** = ``10``
  233. OpenGL texture format ``GL_RGB32F`` where there are three components, each a 32-bit floating-point values.
  234. .. _class_Image_constant_FORMAT_RGBAF:
  235. .. rst-class:: classref-enumeration-constant
  236. :ref:`Format<enum_Image_Format>` **FORMAT_RGBAF** = ``11``
  237. OpenGL texture format ``GL_RGBA32F`` where there are four components, each a 32-bit floating-point values.
  238. .. _class_Image_constant_FORMAT_RH:
  239. .. rst-class:: classref-enumeration-constant
  240. :ref:`Format<enum_Image_Format>` **FORMAT_RH** = ``12``
  241. OpenGL texture format ``GL_R16F`` where there's one component, a 16-bit "half-precision" floating-point value.
  242. .. _class_Image_constant_FORMAT_RGH:
  243. .. rst-class:: classref-enumeration-constant
  244. :ref:`Format<enum_Image_Format>` **FORMAT_RGH** = ``13``
  245. OpenGL texture format ``GL_RG16F`` where there are two components, each a 16-bit "half-precision" floating-point value.
  246. .. _class_Image_constant_FORMAT_RGBH:
  247. .. rst-class:: classref-enumeration-constant
  248. :ref:`Format<enum_Image_Format>` **FORMAT_RGBH** = ``14``
  249. OpenGL texture format ``GL_RGB16F`` where there are three components, each a 16-bit "half-precision" floating-point value.
  250. .. _class_Image_constant_FORMAT_RGBAH:
  251. .. rst-class:: classref-enumeration-constant
  252. :ref:`Format<enum_Image_Format>` **FORMAT_RGBAH** = ``15``
  253. OpenGL texture format ``GL_RGBA16F`` where there are four components, each a 16-bit "half-precision" floating-point value.
  254. .. _class_Image_constant_FORMAT_RGBE9995:
  255. .. rst-class:: classref-enumeration-constant
  256. :ref:`Format<enum_Image_Format>` **FORMAT_RGBE9995** = ``16``
  257. A special OpenGL texture format where the three color components have 9 bits of precision and all three share a single 5-bit exponent.
  258. .. _class_Image_constant_FORMAT_DXT1:
  259. .. rst-class:: classref-enumeration-constant
  260. :ref:`Format<enum_Image_Format>` **FORMAT_DXT1** = ``17``
  261. The `S3TC <https://en.wikipedia.org/wiki/S3_Texture_Compression>`__ texture format that uses Block Compression 1, and is the smallest variation of S3TC, only providing 1 bit of alpha and color data being premultiplied with alpha.
  262. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, an sRGB to linear color space conversion is performed.
  263. .. _class_Image_constant_FORMAT_DXT3:
  264. .. rst-class:: classref-enumeration-constant
  265. :ref:`Format<enum_Image_Format>` **FORMAT_DXT3** = ``18``
  266. The `S3TC <https://en.wikipedia.org/wiki/S3_Texture_Compression>`__ texture format that uses Block Compression 2, and color data is interpreted as not having been premultiplied by alpha. Well suited for images with sharp alpha transitions between translucent and opaque areas.
  267. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, an sRGB to linear color space conversion is performed.
  268. .. _class_Image_constant_FORMAT_DXT5:
  269. .. rst-class:: classref-enumeration-constant
  270. :ref:`Format<enum_Image_Format>` **FORMAT_DXT5** = ``19``
  271. The `S3TC <https://en.wikipedia.org/wiki/S3_Texture_Compression>`__ texture format also known as Block Compression 3 or BC3 that contains 64 bits of alpha channel data followed by 64 bits of DXT1-encoded color data. Color data is not premultiplied by alpha, same as DXT3. DXT5 generally produces superior results for transparent gradients compared to DXT3.
  272. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, an sRGB to linear color space conversion is performed.
  273. .. _class_Image_constant_FORMAT_RGTC_R:
  274. .. rst-class:: classref-enumeration-constant
  275. :ref:`Format<enum_Image_Format>` **FORMAT_RGTC_R** = ``20``
  276. Texture format that uses `Red Green Texture Compression <https://www.khronos.org/opengl/wiki/Red_Green_Texture_Compression>`__, normalizing the red channel data using the same compression algorithm that DXT5 uses for the alpha channel.
  277. .. _class_Image_constant_FORMAT_RGTC_RG:
  278. .. rst-class:: classref-enumeration-constant
  279. :ref:`Format<enum_Image_Format>` **FORMAT_RGTC_RG** = ``21``
  280. Texture format that uses `Red Green Texture Compression <https://www.khronos.org/opengl/wiki/Red_Green_Texture_Compression>`__, normalizing the red and green channel data using the same compression algorithm that DXT5 uses for the alpha channel.
  281. .. _class_Image_constant_FORMAT_BPTC_RGBA:
  282. .. rst-class:: classref-enumeration-constant
  283. :ref:`Format<enum_Image_Format>` **FORMAT_BPTC_RGBA** = ``22``
  284. Texture format that uses `BPTC <https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression>`__ compression with unsigned normalized RGBA components.
  285. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, an sRGB to linear color space conversion is performed.
  286. .. _class_Image_constant_FORMAT_BPTC_RGBF:
  287. .. rst-class:: classref-enumeration-constant
  288. :ref:`Format<enum_Image_Format>` **FORMAT_BPTC_RGBF** = ``23``
  289. Texture format that uses `BPTC <https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression>`__ compression with signed floating-point RGB components.
  290. .. _class_Image_constant_FORMAT_BPTC_RGBFU:
  291. .. rst-class:: classref-enumeration-constant
  292. :ref:`Format<enum_Image_Format>` **FORMAT_BPTC_RGBFU** = ``24``
  293. Texture format that uses `BPTC <https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression>`__ compression with unsigned floating-point RGB components.
  294. .. _class_Image_constant_FORMAT_ETC:
  295. .. rst-class:: classref-enumeration-constant
  296. :ref:`Format<enum_Image_Format>` **FORMAT_ETC** = ``25``
  297. `Ericsson Texture Compression format 1 <https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC1>`__, also referred to as "ETC1", and is part of the OpenGL ES graphics standard. This format cannot store an alpha channel.
  298. .. _class_Image_constant_FORMAT_ETC2_R11:
  299. .. rst-class:: classref-enumeration-constant
  300. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_R11** = ``26``
  301. `Ericsson Texture Compression format 2 <https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC>`__ (``R11_EAC`` variant), which provides one channel of unsigned data.
  302. .. _class_Image_constant_FORMAT_ETC2_R11S:
  303. .. rst-class:: classref-enumeration-constant
  304. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_R11S** = ``27``
  305. `Ericsson Texture Compression format 2 <https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC>`__ (``SIGNED_R11_EAC`` variant), which provides one channel of signed data.
  306. .. _class_Image_constant_FORMAT_ETC2_RG11:
  307. .. rst-class:: classref-enumeration-constant
  308. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RG11** = ``28``
  309. `Ericsson Texture Compression format 2 <https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC>`__ (``RG11_EAC`` variant), which provides two channels of unsigned data.
  310. .. _class_Image_constant_FORMAT_ETC2_RG11S:
  311. .. rst-class:: classref-enumeration-constant
  312. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RG11S** = ``29``
  313. `Ericsson Texture Compression format 2 <https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC>`__ (``SIGNED_RG11_EAC`` variant), which provides two channels of signed data.
  314. .. _class_Image_constant_FORMAT_ETC2_RGB8:
  315. .. rst-class:: classref-enumeration-constant
  316. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RGB8** = ``30``
  317. `Ericsson Texture Compression format 2 <https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC>`__ (``RGB8`` variant), which is a follow-up of ETC1 and compresses RGB888 data.
  318. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, an sRGB to linear color space conversion is performed.
  319. .. _class_Image_constant_FORMAT_ETC2_RGBA8:
  320. .. rst-class:: classref-enumeration-constant
  321. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RGBA8** = ``31``
  322. `Ericsson Texture Compression format 2 <https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC>`__ (``RGBA8``\ variant), which compresses RGBA8888 data with full alpha support.
  323. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, an sRGB to linear color space conversion is performed.
  324. .. _class_Image_constant_FORMAT_ETC2_RGB8A1:
  325. .. rst-class:: classref-enumeration-constant
  326. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RGB8A1** = ``32``
  327. `Ericsson Texture Compression format 2 <https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC>`__ (``RGB8_PUNCHTHROUGH_ALPHA1`` variant), which compresses RGBA data to make alpha either fully transparent or fully opaque.
  328. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, an sRGB to linear color space conversion is performed.
  329. .. _class_Image_constant_FORMAT_ETC2_RA_AS_RG:
  330. .. rst-class:: classref-enumeration-constant
  331. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RA_AS_RG** = ``33``
  332. `Ericsson Texture Compression format 2 <https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC>`__ (``RGBA8`` variant), which compresses RA data and interprets it as two channels (red and green). See also :ref:`FORMAT_ETC2_RGBA8<class_Image_constant_FORMAT_ETC2_RGBA8>`.
  333. .. _class_Image_constant_FORMAT_DXT5_RA_AS_RG:
  334. .. rst-class:: classref-enumeration-constant
  335. :ref:`Format<enum_Image_Format>` **FORMAT_DXT5_RA_AS_RG** = ``34``
  336. The `S3TC <https://en.wikipedia.org/wiki/S3_Texture_Compression>`__ texture format also known as Block Compression 3 or BC3, which compresses RA data and interprets it as two channels (red and green). See also :ref:`FORMAT_DXT5<class_Image_constant_FORMAT_DXT5>`.
  337. .. _class_Image_constant_FORMAT_ASTC_4x4:
  338. .. rst-class:: classref-enumeration-constant
  339. :ref:`Format<enum_Image_Format>` **FORMAT_ASTC_4x4** = ``35``
  340. `Adaptive Scalable Texture Compression <https://en.wikipedia.org/wiki/Adaptive_scalable_texture_compression>`__. This implements the 4ร—4 (high quality) mode.
  341. .. _class_Image_constant_FORMAT_ASTC_4x4_HDR:
  342. .. rst-class:: classref-enumeration-constant
  343. :ref:`Format<enum_Image_Format>` **FORMAT_ASTC_4x4_HDR** = ``36``
  344. Same format as :ref:`FORMAT_ASTC_4x4<class_Image_constant_FORMAT_ASTC_4x4>`, but with the hint to let the GPU know it is used for HDR.
  345. .. _class_Image_constant_FORMAT_ASTC_8x8:
  346. .. rst-class:: classref-enumeration-constant
  347. :ref:`Format<enum_Image_Format>` **FORMAT_ASTC_8x8** = ``37``
  348. `Adaptive Scalable Texture Compression <https://en.wikipedia.org/wiki/Adaptive_scalable_texture_compression>`__. This implements the 8ร—8 (low quality) mode.
  349. .. _class_Image_constant_FORMAT_ASTC_8x8_HDR:
  350. .. rst-class:: classref-enumeration-constant
  351. :ref:`Format<enum_Image_Format>` **FORMAT_ASTC_8x8_HDR** = ``38``
  352. Same format as :ref:`FORMAT_ASTC_8x8<class_Image_constant_FORMAT_ASTC_8x8>`, but with the hint to let the GPU know it is used for HDR.
  353. .. _class_Image_constant_FORMAT_MAX:
  354. .. rst-class:: classref-enumeration-constant
  355. :ref:`Format<enum_Image_Format>` **FORMAT_MAX** = ``39``
  356. Represents the size of the :ref:`Format<enum_Image_Format>` enum.
  357. .. rst-class:: classref-item-separator
  358. ----
  359. .. _enum_Image_Interpolation:
  360. .. rst-class:: classref-enumeration
  361. enum **Interpolation**: :ref:`๐Ÿ”—<enum_Image_Interpolation>`
  362. .. _class_Image_constant_INTERPOLATE_NEAREST:
  363. .. rst-class:: classref-enumeration-constant
  364. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_NEAREST** = ``0``
  365. Performs nearest-neighbor interpolation. If the image is resized, it will be pixelated.
  366. .. _class_Image_constant_INTERPOLATE_BILINEAR:
  367. .. rst-class:: classref-enumeration-constant
  368. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_BILINEAR** = ``1``
  369. Performs bilinear interpolation. If the image is resized, it will be blurry. This mode is faster than :ref:`INTERPOLATE_CUBIC<class_Image_constant_INTERPOLATE_CUBIC>`, but it results in lower quality.
  370. .. _class_Image_constant_INTERPOLATE_CUBIC:
  371. .. rst-class:: classref-enumeration-constant
  372. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_CUBIC** = ``2``
  373. Performs cubic interpolation. If the image is resized, it will be blurry. This mode often gives better results compared to :ref:`INTERPOLATE_BILINEAR<class_Image_constant_INTERPOLATE_BILINEAR>`, at the cost of being slower.
  374. .. _class_Image_constant_INTERPOLATE_TRILINEAR:
  375. .. rst-class:: classref-enumeration-constant
  376. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_TRILINEAR** = ``3``
  377. Performs bilinear separately on the two most-suited mipmap levels, then linearly interpolates between them.
  378. It's slower than :ref:`INTERPOLATE_BILINEAR<class_Image_constant_INTERPOLATE_BILINEAR>`, but produces higher-quality results with far fewer aliasing artifacts.
  379. If the image does not have mipmaps, they will be generated and used internally, but no mipmaps will be generated on the resulting image.
  380. \ **Note:** If you intend to scale multiple copies of the original image, it's better to call :ref:`generate_mipmaps<class_Image_method_generate_mipmaps>`] on it in advance, to avoid wasting processing power in generating them again and again.
  381. On the other hand, if the image already has mipmaps, they will be used, and a new set will be generated for the resulting image.
  382. .. _class_Image_constant_INTERPOLATE_LANCZOS:
  383. .. rst-class:: classref-enumeration-constant
  384. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_LANCZOS** = ``4``
  385. Performs Lanczos interpolation. This is the slowest image resizing mode, but it typically gives the best results, especially when downscaling images.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _enum_Image_AlphaMode:
  389. .. rst-class:: classref-enumeration
  390. enum **AlphaMode**: :ref:`๐Ÿ”—<enum_Image_AlphaMode>`
  391. .. _class_Image_constant_ALPHA_NONE:
  392. .. rst-class:: classref-enumeration-constant
  393. :ref:`AlphaMode<enum_Image_AlphaMode>` **ALPHA_NONE** = ``0``
  394. Image does not have alpha.
  395. .. _class_Image_constant_ALPHA_BIT:
  396. .. rst-class:: classref-enumeration-constant
  397. :ref:`AlphaMode<enum_Image_AlphaMode>` **ALPHA_BIT** = ``1``
  398. Image stores alpha in a single bit.
  399. .. _class_Image_constant_ALPHA_BLEND:
  400. .. rst-class:: classref-enumeration-constant
  401. :ref:`AlphaMode<enum_Image_AlphaMode>` **ALPHA_BLEND** = ``2``
  402. Image uses alpha.
  403. .. rst-class:: classref-item-separator
  404. ----
  405. .. _enum_Image_CompressMode:
  406. .. rst-class:: classref-enumeration
  407. enum **CompressMode**: :ref:`๐Ÿ”—<enum_Image_CompressMode>`
  408. .. _class_Image_constant_COMPRESS_S3TC:
  409. .. rst-class:: classref-enumeration-constant
  410. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_S3TC** = ``0``
  411. Use S3TC compression.
  412. .. _class_Image_constant_COMPRESS_ETC:
  413. .. rst-class:: classref-enumeration-constant
  414. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_ETC** = ``1``
  415. Use ETC compression.
  416. .. _class_Image_constant_COMPRESS_ETC2:
  417. .. rst-class:: classref-enumeration-constant
  418. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_ETC2** = ``2``
  419. Use ETC2 compression.
  420. .. _class_Image_constant_COMPRESS_BPTC:
  421. .. rst-class:: classref-enumeration-constant
  422. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_BPTC** = ``3``
  423. Use BPTC compression.
  424. .. _class_Image_constant_COMPRESS_ASTC:
  425. .. rst-class:: classref-enumeration-constant
  426. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_ASTC** = ``4``
  427. Use ASTC compression.
  428. .. _class_Image_constant_COMPRESS_MAX:
  429. .. rst-class:: classref-enumeration-constant
  430. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_MAX** = ``5``
  431. Represents the size of the :ref:`CompressMode<enum_Image_CompressMode>` enum.
  432. .. rst-class:: classref-item-separator
  433. ----
  434. .. _enum_Image_UsedChannels:
  435. .. rst-class:: classref-enumeration
  436. enum **UsedChannels**: :ref:`๐Ÿ”—<enum_Image_UsedChannels>`
  437. .. _class_Image_constant_USED_CHANNELS_L:
  438. .. rst-class:: classref-enumeration-constant
  439. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_L** = ``0``
  440. The image only uses one channel for luminance (grayscale).
  441. .. _class_Image_constant_USED_CHANNELS_LA:
  442. .. rst-class:: classref-enumeration-constant
  443. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_LA** = ``1``
  444. The image uses two channels for luminance and alpha, respectively.
  445. .. _class_Image_constant_USED_CHANNELS_R:
  446. .. rst-class:: classref-enumeration-constant
  447. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_R** = ``2``
  448. The image only uses the red channel.
  449. .. _class_Image_constant_USED_CHANNELS_RG:
  450. .. rst-class:: classref-enumeration-constant
  451. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_RG** = ``3``
  452. The image uses two channels for red and green.
  453. .. _class_Image_constant_USED_CHANNELS_RGB:
  454. .. rst-class:: classref-enumeration-constant
  455. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_RGB** = ``4``
  456. The image uses three channels for red, green, and blue.
  457. .. _class_Image_constant_USED_CHANNELS_RGBA:
  458. .. rst-class:: classref-enumeration-constant
  459. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_RGBA** = ``5``
  460. The image uses four channels for red, green, blue, and alpha.
  461. .. rst-class:: classref-item-separator
  462. ----
  463. .. _enum_Image_CompressSource:
  464. .. rst-class:: classref-enumeration
  465. enum **CompressSource**: :ref:`๐Ÿ”—<enum_Image_CompressSource>`
  466. .. _class_Image_constant_COMPRESS_SOURCE_GENERIC:
  467. .. rst-class:: classref-enumeration-constant
  468. :ref:`CompressSource<enum_Image_CompressSource>` **COMPRESS_SOURCE_GENERIC** = ``0``
  469. Source texture (before compression) is a regular texture. Default for all textures.
  470. .. _class_Image_constant_COMPRESS_SOURCE_SRGB:
  471. .. rst-class:: classref-enumeration-constant
  472. :ref:`CompressSource<enum_Image_CompressSource>` **COMPRESS_SOURCE_SRGB** = ``1``
  473. Source texture (before compression) is in sRGB space.
  474. .. _class_Image_constant_COMPRESS_SOURCE_NORMAL:
  475. .. rst-class:: classref-enumeration-constant
  476. :ref:`CompressSource<enum_Image_CompressSource>` **COMPRESS_SOURCE_NORMAL** = ``2``
  477. Source texture (before compression) is a normal texture (e.g. it can be compressed into two channels).
  478. .. rst-class:: classref-item-separator
  479. ----
  480. .. _enum_Image_ASTCFormat:
  481. .. rst-class:: classref-enumeration
  482. enum **ASTCFormat**: :ref:`๐Ÿ”—<enum_Image_ASTCFormat>`
  483. .. _class_Image_constant_ASTC_FORMAT_4x4:
  484. .. rst-class:: classref-enumeration-constant
  485. :ref:`ASTCFormat<enum_Image_ASTCFormat>` **ASTC_FORMAT_4x4** = ``0``
  486. Hint to indicate that the high quality 4ร—4 ASTC compression format should be used.
  487. .. _class_Image_constant_ASTC_FORMAT_8x8:
  488. .. rst-class:: classref-enumeration-constant
  489. :ref:`ASTCFormat<enum_Image_ASTCFormat>` **ASTC_FORMAT_8x8** = ``1``
  490. Hint to indicate that the low quality 8ร—8 ASTC compression format should be used.
  491. .. rst-class:: classref-section-separator
  492. ----
  493. .. rst-class:: classref-descriptions-group
  494. Constants
  495. ---------
  496. .. _class_Image_constant_MAX_WIDTH:
  497. .. rst-class:: classref-constant
  498. **MAX_WIDTH** = ``16777216`` :ref:`๐Ÿ”—<class_Image_constant_MAX_WIDTH>`
  499. The maximal width allowed for **Image** resources.
  500. .. _class_Image_constant_MAX_HEIGHT:
  501. .. rst-class:: classref-constant
  502. **MAX_HEIGHT** = ``16777216`` :ref:`๐Ÿ”—<class_Image_constant_MAX_HEIGHT>`
  503. The maximal height allowed for **Image** resources.
  504. .. rst-class:: classref-section-separator
  505. ----
  506. .. rst-class:: classref-descriptions-group
  507. Property Descriptions
  508. ---------------------
  509. .. _class_Image_property_data:
  510. .. rst-class:: classref-property
  511. :ref:`Dictionary<class_Dictionary>` **data** = ``{ "data": PackedByteArray(), "format": "Lum8", "height": 0, "mipmaps": false, "width": 0 }`` :ref:`๐Ÿ”—<class_Image_property_data>`
  512. Holds all the image's color data in a given format. See :ref:`Format<enum_Image_Format>` constants.
  513. .. rst-class:: classref-section-separator
  514. ----
  515. .. rst-class:: classref-descriptions-group
  516. Method Descriptions
  517. -------------------
  518. .. _class_Image_method_adjust_bcs:
  519. .. rst-class:: classref-method
  520. |void| **adjust_bcs**\ (\ brightness\: :ref:`float<class_float>`, contrast\: :ref:`float<class_float>`, saturation\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_Image_method_adjust_bcs>`
  521. Adjusts this image's ``brightness``, ``contrast``, and ``saturation`` by the given values. Does not work if the image is compressed (see :ref:`is_compressed<class_Image_method_is_compressed>`).
  522. .. rst-class:: classref-item-separator
  523. ----
  524. .. _class_Image_method_blend_rect:
  525. .. rst-class:: classref-method
  526. |void| **blend_rect**\ (\ src\: :ref:`Image<class_Image>`, src_rect\: :ref:`Rect2i<class_Rect2i>`, dst\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`๐Ÿ”—<class_Image_method_blend_rect>`
  527. Alpha-blends ``src_rect`` from ``src`` image to this image at coordinates ``dst``, clipped accordingly to both image bounds. This image and ``src`` image **must** have the same format. ``src_rect`` with non-positive size is treated as empty.
  528. .. rst-class:: classref-item-separator
  529. ----
  530. .. _class_Image_method_blend_rect_mask:
  531. .. rst-class:: classref-method
  532. |void| **blend_rect_mask**\ (\ src\: :ref:`Image<class_Image>`, mask\: :ref:`Image<class_Image>`, src_rect\: :ref:`Rect2i<class_Rect2i>`, dst\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`๐Ÿ”—<class_Image_method_blend_rect_mask>`
  533. Alpha-blends ``src_rect`` from ``src`` image to this image using ``mask`` image at coordinates ``dst``, clipped accordingly to both image bounds. 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. This image and ``src`` image **must** have the same format. ``src`` image and ``mask`` image **must** have the same size (width and height) but they can have different formats. ``src_rect`` with non-positive size is treated as empty.
  534. .. rst-class:: classref-item-separator
  535. ----
  536. .. _class_Image_method_blit_rect:
  537. .. rst-class:: classref-method
  538. |void| **blit_rect**\ (\ src\: :ref:`Image<class_Image>`, src_rect\: :ref:`Rect2i<class_Rect2i>`, dst\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`๐Ÿ”—<class_Image_method_blit_rect>`
  539. Copies ``src_rect`` from ``src`` image to this image at coordinates ``dst``, clipped accordingly to both image bounds. This image and ``src`` image **must** have the same format. ``src_rect`` with non-positive size is treated as empty.
  540. \ **Note:** The alpha channel data in ``src`` will overwrite the corresponding data in this image at the target position. To blend alpha channels, use :ref:`blend_rect<class_Image_method_blend_rect>` instead.
  541. .. rst-class:: classref-item-separator
  542. ----
  543. .. _class_Image_method_blit_rect_mask:
  544. .. rst-class:: classref-method
  545. |void| **blit_rect_mask**\ (\ src\: :ref:`Image<class_Image>`, mask\: :ref:`Image<class_Image>`, src_rect\: :ref:`Rect2i<class_Rect2i>`, dst\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`๐Ÿ”—<class_Image_method_blit_rect_mask>`
  546. Blits ``src_rect`` area from ``src`` image to this image at the coordinates given by ``dst``, clipped accordingly to both image bounds. ``src`` pixel is copied onto ``dst`` if the corresponding ``mask`` pixel's alpha value is not 0. This image and ``src`` image **must** have the same format. ``src`` image and ``mask`` image **must** have the same size (width and height) but they can have different formats. ``src_rect`` with non-positive size is treated as empty.
  547. .. rst-class:: classref-item-separator
  548. ----
  549. .. _class_Image_method_bump_map_to_normal_map:
  550. .. rst-class:: classref-method
  551. |void| **bump_map_to_normal_map**\ (\ bump_scale\: :ref:`float<class_float>` = 1.0\ ) :ref:`๐Ÿ”—<class_Image_method_bump_map_to_normal_map>`
  552. Converts a bump map to a normal map. A bump map provides a height offset per-pixel, while a normal map provides a normal direction per pixel.
  553. .. rst-class:: classref-item-separator
  554. ----
  555. .. _class_Image_method_clear_mipmaps:
  556. .. rst-class:: classref-method
  557. |void| **clear_mipmaps**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_clear_mipmaps>`
  558. Removes the image's mipmaps.
  559. .. rst-class:: classref-item-separator
  560. ----
  561. .. _class_Image_method_compress:
  562. .. rst-class:: classref-method
  563. :ref:`Error<enum_@GlobalScope_Error>` **compress**\ (\ mode\: :ref:`CompressMode<enum_Image_CompressMode>`, source\: :ref:`CompressSource<enum_Image_CompressSource>` = 0, astc_format\: :ref:`ASTCFormat<enum_Image_ASTCFormat>` = 0\ ) :ref:`๐Ÿ”—<class_Image_method_compress>`
  564. 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.
  565. The ``source`` parameter helps to pick the best compression method for DXT and ETC2 formats. It is ignored for ASTC compression.
  566. For ASTC compression, the ``astc_format`` parameter must be supplied.
  567. .. rst-class:: classref-item-separator
  568. ----
  569. .. _class_Image_method_compress_from_channels:
  570. .. rst-class:: classref-method
  571. :ref:`Error<enum_@GlobalScope_Error>` **compress_from_channels**\ (\ mode\: :ref:`CompressMode<enum_Image_CompressMode>`, channels\: :ref:`UsedChannels<enum_Image_UsedChannels>`, astc_format\: :ref:`ASTCFormat<enum_Image_ASTCFormat>` = 0\ ) :ref:`๐Ÿ”—<class_Image_method_compress_from_channels>`
  572. 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.
  573. This is an alternative to :ref:`compress<class_Image_method_compress>` that lets the user supply the channels used in order for the compressor to pick the best DXT and ETC2 formats. For other formats (non DXT or ETC2), this argument is ignored.
  574. For ASTC compression, the ``astc_format`` parameter must be supplied.
  575. .. rst-class:: classref-item-separator
  576. ----
  577. .. _class_Image_method_compute_image_metrics:
  578. .. rst-class:: classref-method
  579. :ref:`Dictionary<class_Dictionary>` **compute_image_metrics**\ (\ compared_image\: :ref:`Image<class_Image>`, use_luma\: :ref:`bool<class_bool>`\ ) :ref:`๐Ÿ”—<class_Image_method_compute_image_metrics>`
  580. Compute image metrics on the current image and the compared image.
  581. The dictionary contains ``max``, ``mean``, ``mean_squared``, ``root_mean_squared`` and ``peak_snr``.
  582. .. rst-class:: classref-item-separator
  583. ----
  584. .. _class_Image_method_convert:
  585. .. rst-class:: classref-method
  586. |void| **convert**\ (\ format\: :ref:`Format<enum_Image_Format>`\ ) :ref:`๐Ÿ”—<class_Image_method_convert>`
  587. Converts the image's format. See :ref:`Format<enum_Image_Format>` constants.
  588. .. rst-class:: classref-item-separator
  589. ----
  590. .. _class_Image_method_copy_from:
  591. .. rst-class:: classref-method
  592. |void| **copy_from**\ (\ src\: :ref:`Image<class_Image>`\ ) :ref:`๐Ÿ”—<class_Image_method_copy_from>`
  593. Copies ``src`` image to this image.
  594. .. rst-class:: classref-item-separator
  595. ----
  596. .. _class_Image_method_create:
  597. .. rst-class:: classref-method
  598. :ref:`Image<class_Image>` **create**\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, use_mipmaps\: :ref:`bool<class_bool>`, format\: :ref:`Format<enum_Image_Format>`\ ) |static| :ref:`๐Ÿ”—<class_Image_method_create>`
  599. **Deprecated:** Use :ref:`create_empty<class_Image_method_create_empty>`.
  600. Creates an empty image of given size and format. See :ref:`Format<enum_Image_Format>` constants. If ``use_mipmaps`` is ``true``, then generate mipmaps for this image. See the :ref:`generate_mipmaps<class_Image_method_generate_mipmaps>`.
  601. .. rst-class:: classref-item-separator
  602. ----
  603. .. _class_Image_method_create_empty:
  604. .. rst-class:: classref-method
  605. :ref:`Image<class_Image>` **create_empty**\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, use_mipmaps\: :ref:`bool<class_bool>`, format\: :ref:`Format<enum_Image_Format>`\ ) |static| :ref:`๐Ÿ”—<class_Image_method_create_empty>`
  606. Creates an empty image of given size and format. See :ref:`Format<enum_Image_Format>` constants. If ``use_mipmaps`` is ``true``, then generate mipmaps for this image. See the :ref:`generate_mipmaps<class_Image_method_generate_mipmaps>`.
  607. .. rst-class:: classref-item-separator
  608. ----
  609. .. _class_Image_method_create_from_data:
  610. .. rst-class:: classref-method
  611. :ref:`Image<class_Image>` **create_from_data**\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, use_mipmaps\: :ref:`bool<class_bool>`, format\: :ref:`Format<enum_Image_Format>`, data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |static| :ref:`๐Ÿ”—<class_Image_method_create_from_data>`
  612. Creates a new image of given size and format. See :ref:`Format<enum_Image_Format>` constants. Fills the image with the given raw data. If ``use_mipmaps`` is ``true`` then loads mipmaps for this image from ``data``. See :ref:`generate_mipmaps<class_Image_method_generate_mipmaps>`.
  613. .. rst-class:: classref-item-separator
  614. ----
  615. .. _class_Image_method_crop:
  616. .. rst-class:: classref-method
  617. |void| **crop**\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_Image_method_crop>`
  618. 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.
  619. .. rst-class:: classref-item-separator
  620. ----
  621. .. _class_Image_method_decompress:
  622. .. rst-class:: classref-method
  623. :ref:`Error<enum_@GlobalScope_Error>` **decompress**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_decompress>`
  624. Decompresses the image if it is VRAM compressed in a supported format. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` if the format is supported, otherwise :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>`.
  625. \ **Note:** The following formats can be decompressed: DXT, RGTC, BPTC. The formats ETC1 and ETC2 are not supported.
  626. .. rst-class:: classref-item-separator
  627. ----
  628. .. _class_Image_method_detect_alpha:
  629. .. rst-class:: classref-method
  630. :ref:`AlphaMode<enum_Image_AlphaMode>` **detect_alpha**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_detect_alpha>`
  631. Returns :ref:`ALPHA_BLEND<class_Image_constant_ALPHA_BLEND>` if the image has data for alpha values. Returns :ref:`ALPHA_BIT<class_Image_constant_ALPHA_BIT>` if all the alpha values are stored in a single bit. Returns :ref:`ALPHA_NONE<class_Image_constant_ALPHA_NONE>` if no data for alpha values is found.
  632. .. rst-class:: classref-item-separator
  633. ----
  634. .. _class_Image_method_detect_used_channels:
  635. .. rst-class:: classref-method
  636. :ref:`UsedChannels<enum_Image_UsedChannels>` **detect_used_channels**\ (\ source\: :ref:`CompressSource<enum_Image_CompressSource>` = 0\ ) |const| :ref:`๐Ÿ”—<class_Image_method_detect_used_channels>`
  637. Returns the color channels used by this image, as one of the :ref:`UsedChannels<enum_Image_UsedChannels>` constants. If the image is compressed, the original ``source`` must be specified.
  638. .. rst-class:: classref-item-separator
  639. ----
  640. .. _class_Image_method_fill:
  641. .. rst-class:: classref-method
  642. |void| **fill**\ (\ color\: :ref:`Color<class_Color>`\ ) :ref:`๐Ÿ”—<class_Image_method_fill>`
  643. Fills the image with ``color``.
  644. .. rst-class:: classref-item-separator
  645. ----
  646. .. _class_Image_method_fill_rect:
  647. .. rst-class:: classref-method
  648. |void| **fill_rect**\ (\ rect\: :ref:`Rect2i<class_Rect2i>`, color\: :ref:`Color<class_Color>`\ ) :ref:`๐Ÿ”—<class_Image_method_fill_rect>`
  649. Fills ``rect`` with ``color``.
  650. .. rst-class:: classref-item-separator
  651. ----
  652. .. _class_Image_method_fix_alpha_edges:
  653. .. rst-class:: classref-method
  654. |void| **fix_alpha_edges**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_fix_alpha_edges>`
  655. Blends low-alpha pixels with nearby pixels.
  656. .. rst-class:: classref-item-separator
  657. ----
  658. .. _class_Image_method_flip_x:
  659. .. rst-class:: classref-method
  660. |void| **flip_x**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_flip_x>`
  661. Flips the image horizontally.
  662. .. rst-class:: classref-item-separator
  663. ----
  664. .. _class_Image_method_flip_y:
  665. .. rst-class:: classref-method
  666. |void| **flip_y**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_flip_y>`
  667. Flips the image vertically.
  668. .. rst-class:: classref-item-separator
  669. ----
  670. .. _class_Image_method_generate_mipmaps:
  671. .. rst-class:: classref-method
  672. :ref:`Error<enum_@GlobalScope_Error>` **generate_mipmaps**\ (\ renormalize\: :ref:`bool<class_bool>` = false\ ) :ref:`๐Ÿ”—<class_Image_method_generate_mipmaps>`
  673. Generates mipmaps for the image. Mipmaps are precalculated lower-resolution copies of the image that are automatically used if the image needs to be scaled down when rendered. They help improve image quality and performance when rendering. This method returns an error if the image is compressed, in a custom format, or if the image's width/height is ``0``. Enabling ``renormalize`` when generating mipmaps for normal map textures will make sure all resulting vector values are normalized.
  674. It is possible to check if the image has mipmaps by calling :ref:`has_mipmaps<class_Image_method_has_mipmaps>` or :ref:`get_mipmap_count<class_Image_method_get_mipmap_count>`. Calling :ref:`generate_mipmaps<class_Image_method_generate_mipmaps>` on an image that already has mipmaps will replace existing mipmaps in the image.
  675. .. rst-class:: classref-item-separator
  676. ----
  677. .. _class_Image_method_get_data:
  678. .. rst-class:: classref-method
  679. :ref:`PackedByteArray<class_PackedByteArray>` **get_data**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_data>`
  680. Returns a copy of the image's raw data.
  681. .. rst-class:: classref-item-separator
  682. ----
  683. .. _class_Image_method_get_data_size:
  684. .. rst-class:: classref-method
  685. :ref:`int<class_int>` **get_data_size**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_data_size>`
  686. Returns size (in bytes) of the image's raw data.
  687. .. rst-class:: classref-item-separator
  688. ----
  689. .. _class_Image_method_get_format:
  690. .. rst-class:: classref-method
  691. :ref:`Format<enum_Image_Format>` **get_format**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_format>`
  692. Returns the image's format. See :ref:`Format<enum_Image_Format>` constants.
  693. .. rst-class:: classref-item-separator
  694. ----
  695. .. _class_Image_method_get_height:
  696. .. rst-class:: classref-method
  697. :ref:`int<class_int>` **get_height**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_height>`
  698. Returns the image's height.
  699. .. rst-class:: classref-item-separator
  700. ----
  701. .. _class_Image_method_get_mipmap_count:
  702. .. rst-class:: classref-method
  703. :ref:`int<class_int>` **get_mipmap_count**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_mipmap_count>`
  704. Returns the number of mipmap levels or 0 if the image has no mipmaps. The largest main level image is not counted as a mipmap level by this method, so if you want to include it you can add 1 to this count.
  705. .. rst-class:: classref-item-separator
  706. ----
  707. .. _class_Image_method_get_mipmap_offset:
  708. .. rst-class:: classref-method
  709. :ref:`int<class_int>` **get_mipmap_offset**\ (\ mipmap\: :ref:`int<class_int>`\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_mipmap_offset>`
  710. Returns the offset where the image's mipmap with index ``mipmap`` is stored in the :ref:`data<class_Image_property_data>` dictionary.
  711. .. rst-class:: classref-item-separator
  712. ----
  713. .. _class_Image_method_get_pixel:
  714. .. rst-class:: classref-method
  715. :ref:`Color<class_Color>` **get_pixel**\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_pixel>`
  716. Returns the color of the pixel at ``(x, y)``.
  717. This is the same as :ref:`get_pixelv<class_Image_method_get_pixelv>`, but with two integer arguments instead of a :ref:`Vector2i<class_Vector2i>` argument.
  718. .. rst-class:: classref-item-separator
  719. ----
  720. .. _class_Image_method_get_pixelv:
  721. .. rst-class:: classref-method
  722. :ref:`Color<class_Color>` **get_pixelv**\ (\ point\: :ref:`Vector2i<class_Vector2i>`\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_pixelv>`
  723. Returns the color of the pixel at ``point``.
  724. This is the same as :ref:`get_pixel<class_Image_method_get_pixel>`, but with a :ref:`Vector2i<class_Vector2i>` argument instead of two integer arguments.
  725. .. rst-class:: classref-item-separator
  726. ----
  727. .. _class_Image_method_get_region:
  728. .. rst-class:: classref-method
  729. :ref:`Image<class_Image>` **get_region**\ (\ region\: :ref:`Rect2i<class_Rect2i>`\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_region>`
  730. Returns a new **Image** that is a copy of this **Image**'s area specified with ``region``.
  731. .. rst-class:: classref-item-separator
  732. ----
  733. .. _class_Image_method_get_size:
  734. .. rst-class:: classref-method
  735. :ref:`Vector2i<class_Vector2i>` **get_size**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_size>`
  736. Returns the image's size (width and height).
  737. .. rst-class:: classref-item-separator
  738. ----
  739. .. _class_Image_method_get_used_rect:
  740. .. rst-class:: classref-method
  741. :ref:`Rect2i<class_Rect2i>` **get_used_rect**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_used_rect>`
  742. Returns a :ref:`Rect2i<class_Rect2i>` enclosing the visible portion of the image, considering each pixel with a non-zero alpha channel as visible.
  743. .. rst-class:: classref-item-separator
  744. ----
  745. .. _class_Image_method_get_width:
  746. .. rst-class:: classref-method
  747. :ref:`int<class_int>` **get_width**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_get_width>`
  748. Returns the image's width.
  749. .. rst-class:: classref-item-separator
  750. ----
  751. .. _class_Image_method_has_mipmaps:
  752. .. rst-class:: classref-method
  753. :ref:`bool<class_bool>` **has_mipmaps**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_has_mipmaps>`
  754. Returns ``true`` if the image has generated mipmaps.
  755. .. rst-class:: classref-item-separator
  756. ----
  757. .. _class_Image_method_is_compressed:
  758. .. rst-class:: classref-method
  759. :ref:`bool<class_bool>` **is_compressed**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_is_compressed>`
  760. Returns ``true`` if the image is compressed.
  761. .. rst-class:: classref-item-separator
  762. ----
  763. .. _class_Image_method_is_empty:
  764. .. rst-class:: classref-method
  765. :ref:`bool<class_bool>` **is_empty**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_is_empty>`
  766. Returns ``true`` if the image has no data.
  767. .. rst-class:: classref-item-separator
  768. ----
  769. .. _class_Image_method_is_invisible:
  770. .. rst-class:: classref-method
  771. :ref:`bool<class_bool>` **is_invisible**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_is_invisible>`
  772. 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.
  773. .. rst-class:: classref-item-separator
  774. ----
  775. .. _class_Image_method_linear_to_srgb:
  776. .. rst-class:: classref-method
  777. |void| **linear_to_srgb**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_linear_to_srgb>`
  778. Converts the entire image from the linear colorspace to the sRGB colorspace. Only works on images with :ref:`FORMAT_RGB8<class_Image_constant_FORMAT_RGB8>` or :ref:`FORMAT_RGBA8<class_Image_constant_FORMAT_RGBA8>` formats.
  779. .. rst-class:: classref-item-separator
  780. ----
  781. .. _class_Image_method_load:
  782. .. rst-class:: classref-method
  783. :ref:`Error<enum_@GlobalScope_Error>` **load**\ (\ path\: :ref:`String<class_String>`\ ) :ref:`๐Ÿ”—<class_Image_method_load>`
  784. Loads an image from file ``path``. See `Supported image formats <../tutorials/assets_pipeline/importing_images.html#supported-image-formats>`__ for a list of supported image formats and limitations.
  785. \ **Warning:** This method should only be used in the editor or in cases when you need to load external images at run-time, such as images located at the ``user://`` directory, and may not work in exported projects.
  786. See also :ref:`ImageTexture<class_ImageTexture>` description for usage examples.
  787. .. rst-class:: classref-item-separator
  788. ----
  789. .. _class_Image_method_load_bmp_from_buffer:
  790. .. rst-class:: classref-method
  791. :ref:`Error<enum_@GlobalScope_Error>` **load_bmp_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐Ÿ”—<class_Image_method_load_bmp_from_buffer>`
  792. Loads an image from the binary contents of a BMP file.
  793. \ **Note:** Godot's BMP module doesn't support 16-bit per pixel images. Only 1-bit, 4-bit, 8-bit, 24-bit, and 32-bit per pixel images are supported.
  794. \ **Note:** This method is only available in engine builds with the BMP module enabled. By default, the BMP module is enabled, but it can be disabled at build-time using the ``module_bmp_enabled=no`` SCons option.
  795. .. rst-class:: classref-item-separator
  796. ----
  797. .. _class_Image_method_load_from_file:
  798. .. rst-class:: classref-method
  799. :ref:`Image<class_Image>` **load_from_file**\ (\ path\: :ref:`String<class_String>`\ ) |static| :ref:`๐Ÿ”—<class_Image_method_load_from_file>`
  800. Creates a new **Image** and loads data from the specified file.
  801. .. rst-class:: classref-item-separator
  802. ----
  803. .. _class_Image_method_load_jpg_from_buffer:
  804. .. rst-class:: classref-method
  805. :ref:`Error<enum_@GlobalScope_Error>` **load_jpg_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐Ÿ”—<class_Image_method_load_jpg_from_buffer>`
  806. Loads an image from the binary contents of a JPEG file.
  807. .. rst-class:: classref-item-separator
  808. ----
  809. .. _class_Image_method_load_ktx_from_buffer:
  810. .. rst-class:: classref-method
  811. :ref:`Error<enum_@GlobalScope_Error>` **load_ktx_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐Ÿ”—<class_Image_method_load_ktx_from_buffer>`
  812. Loads an image from the binary contents of a `KTX <https://github.com/KhronosGroup/KTX-Software>`__ file. Unlike most image formats, KTX can store VRAM-compressed data and embed mipmaps.
  813. \ **Note:** Godot's libktx implementation only supports 2D images. Cubemaps, texture arrays, and de-padding are not supported.
  814. \ **Note:** This method is only available in engine builds with the KTX module enabled. By default, the KTX module is enabled, but it can be disabled at build-time using the ``module_ktx_enabled=no`` SCons option.
  815. .. rst-class:: classref-item-separator
  816. ----
  817. .. _class_Image_method_load_png_from_buffer:
  818. .. rst-class:: classref-method
  819. :ref:`Error<enum_@GlobalScope_Error>` **load_png_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐Ÿ”—<class_Image_method_load_png_from_buffer>`
  820. Loads an image from the binary contents of a PNG file.
  821. .. rst-class:: classref-item-separator
  822. ----
  823. .. _class_Image_method_load_svg_from_buffer:
  824. .. rst-class:: classref-method
  825. :ref:`Error<enum_@GlobalScope_Error>` **load_svg_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`, scale\: :ref:`float<class_float>` = 1.0\ ) :ref:`๐Ÿ”—<class_Image_method_load_svg_from_buffer>`
  826. Loads an image from the UTF-8 binary contents of an **uncompressed** SVG file (**.svg**).
  827. \ **Note:** Beware when using compressed SVG files (like **.svgz**), they need to be ``decompressed`` before loading.
  828. \ **Note:** This method is only available in engine builds with the SVG module enabled. By default, the SVG module is enabled, but it can be disabled at build-time using the ``module_svg_enabled=no`` SCons option.
  829. .. rst-class:: classref-item-separator
  830. ----
  831. .. _class_Image_method_load_svg_from_string:
  832. .. rst-class:: classref-method
  833. :ref:`Error<enum_@GlobalScope_Error>` **load_svg_from_string**\ (\ svg_str\: :ref:`String<class_String>`, scale\: :ref:`float<class_float>` = 1.0\ ) :ref:`๐Ÿ”—<class_Image_method_load_svg_from_string>`
  834. Loads an image from the string contents of an SVG file (**.svg**).
  835. \ **Note:** This method is only available in engine builds with the SVG module enabled. By default, the SVG module is enabled, but it can be disabled at build-time using the ``module_svg_enabled=no`` SCons option.
  836. .. rst-class:: classref-item-separator
  837. ----
  838. .. _class_Image_method_load_tga_from_buffer:
  839. .. rst-class:: classref-method
  840. :ref:`Error<enum_@GlobalScope_Error>` **load_tga_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐Ÿ”—<class_Image_method_load_tga_from_buffer>`
  841. Loads an image from the binary contents of a TGA file.
  842. \ **Note:** This method is only available in engine builds with the TGA module enabled. By default, the TGA module is enabled, but it can be disabled at build-time using the ``module_tga_enabled=no`` SCons option.
  843. .. rst-class:: classref-item-separator
  844. ----
  845. .. _class_Image_method_load_webp_from_buffer:
  846. .. rst-class:: classref-method
  847. :ref:`Error<enum_@GlobalScope_Error>` **load_webp_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐Ÿ”—<class_Image_method_load_webp_from_buffer>`
  848. Loads an image from the binary contents of a WebP file.
  849. .. rst-class:: classref-item-separator
  850. ----
  851. .. _class_Image_method_normal_map_to_xy:
  852. .. rst-class:: classref-method
  853. |void| **normal_map_to_xy**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_normal_map_to_xy>`
  854. Converts the image's data to represent coordinates on a 3D plane. This is used when the image represents a normal map. A normal map can add lots of detail to a 3D surface without increasing the polygon count.
  855. .. rst-class:: classref-item-separator
  856. ----
  857. .. _class_Image_method_premultiply_alpha:
  858. .. rst-class:: classref-method
  859. |void| **premultiply_alpha**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_premultiply_alpha>`
  860. Multiplies color values with alpha values. Resulting color values for a pixel are ``(color * alpha)/256``. See also :ref:`CanvasItemMaterial.blend_mode<class_CanvasItemMaterial_property_blend_mode>`.
  861. .. rst-class:: classref-item-separator
  862. ----
  863. .. _class_Image_method_resize:
  864. .. rst-class:: classref-method
  865. |void| **resize**\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, interpolation\: :ref:`Interpolation<enum_Image_Interpolation>` = 1\ ) :ref:`๐Ÿ”—<class_Image_method_resize>`
  866. Resizes the image to the given ``width`` and ``height``. New pixels are calculated using the ``interpolation`` mode defined via :ref:`Interpolation<enum_Image_Interpolation>` constants.
  867. .. rst-class:: classref-item-separator
  868. ----
  869. .. _class_Image_method_resize_to_po2:
  870. .. rst-class:: classref-method
  871. |void| **resize_to_po2**\ (\ square\: :ref:`bool<class_bool>` = false, interpolation\: :ref:`Interpolation<enum_Image_Interpolation>` = 1\ ) :ref:`๐Ÿ”—<class_Image_method_resize_to_po2>`
  872. 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. New pixels are calculated using the ``interpolation`` mode defined via :ref:`Interpolation<enum_Image_Interpolation>` constants.
  873. .. rst-class:: classref-item-separator
  874. ----
  875. .. _class_Image_method_rgbe_to_srgb:
  876. .. rst-class:: classref-method
  877. :ref:`Image<class_Image>` **rgbe_to_srgb**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_rgbe_to_srgb>`
  878. Converts a standard RGBE (Red Green Blue Exponent) image to an sRGB image.
  879. .. rst-class:: classref-item-separator
  880. ----
  881. .. _class_Image_method_rotate_90:
  882. .. rst-class:: classref-method
  883. |void| **rotate_90**\ (\ direction\: :ref:`ClockDirection<enum_@GlobalScope_ClockDirection>`\ ) :ref:`๐Ÿ”—<class_Image_method_rotate_90>`
  884. Rotates the image in the specified ``direction`` by ``90`` degrees. The width and height of the image must be greater than ``1``. If the width and height are not equal, the image will be resized.
  885. .. rst-class:: classref-item-separator
  886. ----
  887. .. _class_Image_method_rotate_180:
  888. .. rst-class:: classref-method
  889. |void| **rotate_180**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_rotate_180>`
  890. Rotates the image by ``180`` degrees. The width and height of the image must be greater than ``1``.
  891. .. rst-class:: classref-item-separator
  892. ----
  893. .. _class_Image_method_save_exr:
  894. .. rst-class:: classref-method
  895. :ref:`Error<enum_@GlobalScope_Error>` **save_exr**\ (\ path\: :ref:`String<class_String>`, grayscale\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`๐Ÿ”—<class_Image_method_save_exr>`
  896. Saves the image as an EXR file to ``path``. If ``grayscale`` is ``true`` and the image has only one channel, it will be saved explicitly as monochrome rather than one red channel. This function will return :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>` if Godot was compiled without the TinyEXR module.
  897. \ **Note:** The TinyEXR module is disabled in non-editor builds, which means :ref:`save_exr<class_Image_method_save_exr>` will return :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>` when it is called from an exported project.
  898. .. rst-class:: classref-item-separator
  899. ----
  900. .. _class_Image_method_save_exr_to_buffer:
  901. .. rst-class:: classref-method
  902. :ref:`PackedByteArray<class_PackedByteArray>` **save_exr_to_buffer**\ (\ grayscale\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`๐Ÿ”—<class_Image_method_save_exr_to_buffer>`
  903. Saves the image as an EXR file to a byte array. If ``grayscale`` is ``true`` and the image has only one channel, it will be saved explicitly as monochrome rather than one red channel. This function will return an empty byte array if Godot was compiled without the TinyEXR module.
  904. \ **Note:** The TinyEXR module is disabled in non-editor builds, which means :ref:`save_exr<class_Image_method_save_exr>` will return an empty byte array when it is called from an exported project.
  905. .. rst-class:: classref-item-separator
  906. ----
  907. .. _class_Image_method_save_jpg:
  908. .. rst-class:: classref-method
  909. :ref:`Error<enum_@GlobalScope_Error>` **save_jpg**\ (\ path\: :ref:`String<class_String>`, quality\: :ref:`float<class_float>` = 0.75\ ) |const| :ref:`๐Ÿ”—<class_Image_method_save_jpg>`
  910. Saves the image as a JPEG file to ``path`` with the specified ``quality`` between ``0.01`` and ``1.0`` (inclusive). Higher ``quality`` values result in better-looking output at the cost of larger file sizes. Recommended ``quality`` values are between ``0.75`` and ``0.90``. Even at quality ``1.00``, JPEG compression remains lossy.
  911. \ **Note:** JPEG does not save an alpha channel. If the **Image** contains an alpha channel, the image will still be saved, but the resulting JPEG file won't contain the alpha channel.
  912. .. rst-class:: classref-item-separator
  913. ----
  914. .. _class_Image_method_save_jpg_to_buffer:
  915. .. rst-class:: classref-method
  916. :ref:`PackedByteArray<class_PackedByteArray>` **save_jpg_to_buffer**\ (\ quality\: :ref:`float<class_float>` = 0.75\ ) |const| :ref:`๐Ÿ”—<class_Image_method_save_jpg_to_buffer>`
  917. Saves the image as a JPEG file to a byte array with the specified ``quality`` between ``0.01`` and ``1.0`` (inclusive). Higher ``quality`` values result in better-looking output at the cost of larger byte array sizes (and therefore memory usage). Recommended ``quality`` values are between ``0.75`` and ``0.90``. Even at quality ``1.00``, JPEG compression remains lossy.
  918. \ **Note:** JPEG does not save an alpha channel. If the **Image** contains an alpha channel, the image will still be saved, but the resulting byte array won't contain the alpha channel.
  919. .. rst-class:: classref-item-separator
  920. ----
  921. .. _class_Image_method_save_png:
  922. .. rst-class:: classref-method
  923. :ref:`Error<enum_@GlobalScope_Error>` **save_png**\ (\ path\: :ref:`String<class_String>`\ ) |const| :ref:`๐Ÿ”—<class_Image_method_save_png>`
  924. Saves the image as a PNG file to the file at ``path``.
  925. .. rst-class:: classref-item-separator
  926. ----
  927. .. _class_Image_method_save_png_to_buffer:
  928. .. rst-class:: classref-method
  929. :ref:`PackedByteArray<class_PackedByteArray>` **save_png_to_buffer**\ (\ ) |const| :ref:`๐Ÿ”—<class_Image_method_save_png_to_buffer>`
  930. Saves the image as a PNG file to a byte array.
  931. .. rst-class:: classref-item-separator
  932. ----
  933. .. _class_Image_method_save_webp:
  934. .. rst-class:: classref-method
  935. :ref:`Error<enum_@GlobalScope_Error>` **save_webp**\ (\ path\: :ref:`String<class_String>`, lossy\: :ref:`bool<class_bool>` = false, quality\: :ref:`float<class_float>` = 0.75\ ) |const| :ref:`๐Ÿ”—<class_Image_method_save_webp>`
  936. Saves the image as a WebP (Web Picture) file to the file at ``path``. By default it will save lossless. If ``lossy`` is ``true``, the image will be saved lossy, using the ``quality`` setting between ``0.0`` and ``1.0`` (inclusive). Lossless WebP offers more efficient compression than PNG.
  937. \ **Note:** The WebP format is limited to a size of 16383ร—16383 pixels, while PNG can save larger images.
  938. .. rst-class:: classref-item-separator
  939. ----
  940. .. _class_Image_method_save_webp_to_buffer:
  941. .. rst-class:: classref-method
  942. :ref:`PackedByteArray<class_PackedByteArray>` **save_webp_to_buffer**\ (\ lossy\: :ref:`bool<class_bool>` = false, quality\: :ref:`float<class_float>` = 0.75\ ) |const| :ref:`๐Ÿ”—<class_Image_method_save_webp_to_buffer>`
  943. Saves the image as a WebP (Web Picture) file to a byte array. By default it will save lossless. If ``lossy`` is ``true``, the image will be saved lossy, using the ``quality`` setting between ``0.0`` and ``1.0`` (inclusive). Lossless WebP offers more efficient compression than PNG.
  944. \ **Note:** The WebP format is limited to a size of 16383ร—16383 pixels, while PNG can save larger images.
  945. .. rst-class:: classref-item-separator
  946. ----
  947. .. _class_Image_method_set_data:
  948. .. rst-class:: classref-method
  949. |void| **set_data**\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, use_mipmaps\: :ref:`bool<class_bool>`, format\: :ref:`Format<enum_Image_Format>`, data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐Ÿ”—<class_Image_method_set_data>`
  950. Overwrites data of an existing **Image**. Non-static equivalent of :ref:`create_from_data<class_Image_method_create_from_data>`.
  951. .. rst-class:: classref-item-separator
  952. ----
  953. .. _class_Image_method_set_pixel:
  954. .. rst-class:: classref-method
  955. |void| **set_pixel**\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`, color\: :ref:`Color<class_Color>`\ ) :ref:`๐Ÿ”—<class_Image_method_set_pixel>`
  956. Sets the :ref:`Color<class_Color>` of the pixel at ``(x, y)`` to ``color``.
  957. .. tabs::
  958. .. code-tab:: gdscript
  959. var img_width = 10
  960. var img_height = 5
  961. var img = Image.create(img_width, img_height, false, Image.FORMAT_RGBA8)
  962. img.set_pixel(1, 2, Color.RED) # Sets the color at (1, 2) to red.
  963. .. code-tab:: csharp
  964. int imgWidth = 10;
  965. int imgHeight = 5;
  966. var img = Image.Create(imgWidth, imgHeight, false, Image.Format.Rgba8);
  967. img.SetPixel(1, 2, Colors.Red); // Sets the color at (1, 2) to red.
  968. This is the same as :ref:`set_pixelv<class_Image_method_set_pixelv>`, but with a two integer arguments instead of a :ref:`Vector2i<class_Vector2i>` argument.
  969. .. rst-class:: classref-item-separator
  970. ----
  971. .. _class_Image_method_set_pixelv:
  972. .. rst-class:: classref-method
  973. |void| **set_pixelv**\ (\ point\: :ref:`Vector2i<class_Vector2i>`, color\: :ref:`Color<class_Color>`\ ) :ref:`๐Ÿ”—<class_Image_method_set_pixelv>`
  974. Sets the :ref:`Color<class_Color>` of the pixel at ``point`` to ``color``.
  975. .. tabs::
  976. .. code-tab:: gdscript
  977. var img_width = 10
  978. var img_height = 5
  979. var img = Image.create(img_width, img_height, false, Image.FORMAT_RGBA8)
  980. img.set_pixelv(Vector2i(1, 2), Color.RED) # Sets the color at (1, 2) to red.
  981. .. code-tab:: csharp
  982. int imgWidth = 10;
  983. int imgHeight = 5;
  984. var img = Image.Create(imgWidth, imgHeight, false, Image.Format.Rgba8);
  985. img.SetPixelv(new Vector2I(1, 2), Colors.Red); // Sets the color at (1, 2) to red.
  986. This is the same as :ref:`set_pixel<class_Image_method_set_pixel>`, but with a :ref:`Vector2i<class_Vector2i>` argument instead of two integer arguments.
  987. .. rst-class:: classref-item-separator
  988. ----
  989. .. _class_Image_method_shrink_x2:
  990. .. rst-class:: classref-method
  991. |void| **shrink_x2**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_shrink_x2>`
  992. Shrinks the image by a factor of 2 on each axis (this divides the pixel count by 4).
  993. .. rst-class:: classref-item-separator
  994. ----
  995. .. _class_Image_method_srgb_to_linear:
  996. .. rst-class:: classref-method
  997. |void| **srgb_to_linear**\ (\ ) :ref:`๐Ÿ”—<class_Image_method_srgb_to_linear>`
  998. Converts the raw data from the sRGB colorspace to a linear scale. Only works on images with :ref:`FORMAT_RGB8<class_Image_constant_FORMAT_RGB8>` or :ref:`FORMAT_RGBA8<class_Image_constant_FORMAT_RGBA8>` formats.
  999. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  1000. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  1001. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  1002. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  1003. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  1004. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  1005. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  1006. .. |void| replace:: :abbr:`void (No return value.)`