class_image.rst 117 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985
  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:** Methods that modify the image data cannot be used on VRAM-compressed images. Use :ref:`decompress()<class_Image_method_decompress>` to convert the image to an uncompressed format first.
  17. \ **Note:** The maximum image size is 16384×16384 pixels due to graphics hardware limitations. Larger images may fail to import.
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - :doc:`Importing images <../tutorials/assets_pipeline/importing_images>`
  22. - :doc:`Runtime file loading and saving <../tutorials/io/runtime_file_loading_and_saving>`
  23. .. rst-class:: classref-reftable-group
  24. Properties
  25. ----------
  26. .. table::
  27. :widths: auto
  28. +-------------------------------------+----------------------------------------+------------------------------------------------------------------------------------------------+
  29. | :ref:`Dictionary<class_Dictionary>` | :ref:`data<class_Image_property_data>` | ``{ "data": PackedByteArray(), "format": "Lum8", "height": 0, "mipmaps": false, "width": 0 }`` |
  30. +-------------------------------------+----------------------------------------+------------------------------------------------------------------------------------------------+
  31. .. rst-class:: classref-reftable-group
  32. Methods
  33. -------
  34. .. table::
  35. :widths: auto
  36. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | |void| | :ref:`adjust_bcs<class_Image_method_adjust_bcs>`\ (\ brightness\: :ref:`float<class_float>`, contrast\: :ref:`float<class_float>`, saturation\: :ref:`float<class_float>`\ ) |
  38. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | |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>`\ ) |
  40. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | |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>`\ ) |
  42. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | |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>`\ ) |
  44. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | |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>`\ ) |
  46. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | |void| | :ref:`bump_map_to_normal_map<class_Image_method_bump_map_to_normal_map>`\ (\ bump_scale\: :ref:`float<class_float>` = 1.0\ ) |
  48. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | |void| | :ref:`clear_mipmaps<class_Image_method_clear_mipmaps>`\ (\ ) |
  50. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :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\ ) |
  52. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :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\ ) |
  54. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :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>`\ ) |
  56. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | |void| | :ref:`convert<class_Image_method_convert>`\ (\ format\: :ref:`Format<enum_Image_Format>`\ ) |
  58. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | |void| | :ref:`copy_from<class_Image_method_copy_from>`\ (\ src\: :ref:`Image<class_Image>`\ ) |
  60. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :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| |
  62. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :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| |
  64. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :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| |
  66. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | |void| | :ref:`crop<class_Image_method_crop>`\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`\ ) |
  68. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`decompress<class_Image_method_decompress>`\ (\ ) |
  70. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`AlphaMode<enum_Image_AlphaMode>` | :ref:`detect_alpha<class_Image_method_detect_alpha>`\ (\ ) |const| |
  72. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`UsedChannels<enum_Image_UsedChannels>` | :ref:`detect_used_channels<class_Image_method_detect_used_channels>`\ (\ source\: :ref:`CompressSource<enum_Image_CompressSource>` = 0\ ) |const| |
  74. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | |void| | :ref:`fill<class_Image_method_fill>`\ (\ color\: :ref:`Color<class_Color>`\ ) |
  76. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | |void| | :ref:`fill_rect<class_Image_method_fill_rect>`\ (\ rect\: :ref:`Rect2i<class_Rect2i>`, color\: :ref:`Color<class_Color>`\ ) |
  78. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | |void| | :ref:`fix_alpha_edges<class_Image_method_fix_alpha_edges>`\ (\ ) |
  80. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | |void| | :ref:`flip_x<class_Image_method_flip_x>`\ (\ ) |
  82. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | |void| | :ref:`flip_y<class_Image_method_flip_y>`\ (\ ) |
  84. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`generate_mipmaps<class_Image_method_generate_mipmaps>`\ (\ renormalize\: :ref:`bool<class_bool>` = false\ ) |
  86. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`get_data<class_Image_method_get_data>`\ (\ ) |const| |
  88. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | :ref:`int<class_int>` | :ref:`get_data_size<class_Image_method_get_data_size>`\ (\ ) |const| |
  90. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`Format<enum_Image_Format>` | :ref:`get_format<class_Image_method_get_format>`\ (\ ) |const| |
  92. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`int<class_int>` | :ref:`get_height<class_Image_method_get_height>`\ (\ ) |const| |
  94. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`int<class_int>` | :ref:`get_mipmap_count<class_Image_method_get_mipmap_count>`\ (\ ) |const| |
  96. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`int<class_int>` | :ref:`get_mipmap_offset<class_Image_method_get_mipmap_offset>`\ (\ mipmap\: :ref:`int<class_int>`\ ) |const| |
  98. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`Color<class_Color>` | :ref:`get_pixel<class_Image_method_get_pixel>`\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`\ ) |const| |
  100. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`Color<class_Color>` | :ref:`get_pixelv<class_Image_method_get_pixelv>`\ (\ point\: :ref:`Vector2i<class_Vector2i>`\ ) |const| |
  102. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`Image<class_Image>` | :ref:`get_region<class_Image_method_get_region>`\ (\ region\: :ref:`Rect2i<class_Rect2i>`\ ) |const| |
  104. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`Vector2i<class_Vector2i>` | :ref:`get_size<class_Image_method_get_size>`\ (\ ) |const| |
  106. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`Rect2i<class_Rect2i>` | :ref:`get_used_rect<class_Image_method_get_used_rect>`\ (\ ) |const| |
  108. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`int<class_int>` | :ref:`get_width<class_Image_method_get_width>`\ (\ ) |const| |
  110. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | :ref:`bool<class_bool>` | :ref:`has_mipmaps<class_Image_method_has_mipmaps>`\ (\ ) |const| |
  112. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`bool<class_bool>` | :ref:`is_compressed<class_Image_method_is_compressed>`\ (\ ) |const| |
  114. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`bool<class_bool>` | :ref:`is_empty<class_Image_method_is_empty>`\ (\ ) |const| |
  116. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`bool<class_bool>` | :ref:`is_invisible<class_Image_method_is_invisible>`\ (\ ) |const| |
  118. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | |void| | :ref:`linear_to_srgb<class_Image_method_linear_to_srgb>`\ (\ ) |
  120. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load<class_Image_method_load>`\ (\ path\: :ref:`String<class_String>`\ ) |
  122. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_bmp_from_buffer<class_Image_method_load_bmp_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  124. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_dds_from_buffer<class_Image_method_load_dds_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  126. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | :ref:`Image<class_Image>` | :ref:`load_from_file<class_Image_method_load_from_file>`\ (\ path\: :ref:`String<class_String>`\ ) |static| |
  128. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_jpg_from_buffer<class_Image_method_load_jpg_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  130. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_ktx_from_buffer<class_Image_method_load_ktx_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  132. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_png_from_buffer<class_Image_method_load_png_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  134. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | :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\ ) |
  136. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | :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\ ) |
  138. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_tga_from_buffer<class_Image_method_load_tga_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  140. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_webp_from_buffer<class_Image_method_load_webp_from_buffer>`\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  142. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | |void| | :ref:`normal_map_to_xy<class_Image_method_normal_map_to_xy>`\ (\ ) |
  144. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | |void| | :ref:`premultiply_alpha<class_Image_method_premultiply_alpha>`\ (\ ) |
  146. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | |void| | :ref:`resize<class_Image_method_resize>`\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, interpolation\: :ref:`Interpolation<enum_Image_Interpolation>` = 1\ ) |
  148. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. | |void| | :ref:`resize_to_po2<class_Image_method_resize_to_po2>`\ (\ square\: :ref:`bool<class_bool>` = false, interpolation\: :ref:`Interpolation<enum_Image_Interpolation>` = 1\ ) |
  150. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  151. | :ref:`Image<class_Image>` | :ref:`rgbe_to_srgb<class_Image_method_rgbe_to_srgb>`\ (\ ) |
  152. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  153. | |void| | :ref:`rotate_90<class_Image_method_rotate_90>`\ (\ direction\: :ref:`ClockDirection<enum_@GlobalScope_ClockDirection>`\ ) |
  154. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  155. | |void| | :ref:`rotate_180<class_Image_method_rotate_180>`\ (\ ) |
  156. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  157. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save_dds<class_Image_method_save_dds>`\ (\ path\: :ref:`String<class_String>`\ ) |const| |
  158. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  159. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`save_dds_to_buffer<class_Image_method_save_dds_to_buffer>`\ (\ ) |const| |
  160. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  161. | :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| |
  162. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  163. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`save_exr_to_buffer<class_Image_method_save_exr_to_buffer>`\ (\ grayscale\: :ref:`bool<class_bool>` = false\ ) |const| |
  164. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  165. | :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| |
  166. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  167. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`save_jpg_to_buffer<class_Image_method_save_jpg_to_buffer>`\ (\ quality\: :ref:`float<class_float>` = 0.75\ ) |const| |
  168. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  169. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save_png<class_Image_method_save_png>`\ (\ path\: :ref:`String<class_String>`\ ) |const| |
  170. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  171. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`save_png_to_buffer<class_Image_method_save_png_to_buffer>`\ (\ ) |const| |
  172. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  173. | :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| |
  174. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  175. | :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| |
  176. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  177. | |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>`\ ) |
  178. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  179. | |void| | :ref:`set_pixel<class_Image_method_set_pixel>`\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`, color\: :ref:`Color<class_Color>`\ ) |
  180. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  181. | |void| | :ref:`set_pixelv<class_Image_method_set_pixelv>`\ (\ point\: :ref:`Vector2i<class_Vector2i>`, color\: :ref:`Color<class_Color>`\ ) |
  182. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  183. | |void| | :ref:`shrink_x2<class_Image_method_shrink_x2>`\ (\ ) |
  184. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  185. | |void| | :ref:`srgb_to_linear<class_Image_method_srgb_to_linear>`\ (\ ) |
  186. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  187. .. rst-class:: classref-section-separator
  188. ----
  189. .. rst-class:: classref-descriptions-group
  190. Enumerations
  191. ------------
  192. .. _enum_Image_Format:
  193. .. rst-class:: classref-enumeration
  194. enum **Format**: :ref:`🔗<enum_Image_Format>`
  195. .. _class_Image_constant_FORMAT_L8:
  196. .. rst-class:: classref-enumeration-constant
  197. :ref:`Format<enum_Image_Format>` **FORMAT_L8** = ``0``
  198. Texture format with a single 8-bit depth representing luminance.
  199. .. _class_Image_constant_FORMAT_LA8:
  200. .. rst-class:: classref-enumeration-constant
  201. :ref:`Format<enum_Image_Format>` **FORMAT_LA8** = ``1``
  202. OpenGL texture format with two values, luminance and alpha each stored with 8 bits.
  203. .. _class_Image_constant_FORMAT_R8:
  204. .. rst-class:: classref-enumeration-constant
  205. :ref:`Format<enum_Image_Format>` **FORMAT_R8** = ``2``
  206. OpenGL texture format ``RED`` with a single component and a bitdepth of 8.
  207. .. _class_Image_constant_FORMAT_RG8:
  208. .. rst-class:: classref-enumeration-constant
  209. :ref:`Format<enum_Image_Format>` **FORMAT_RG8** = ``3``
  210. OpenGL texture format ``RG`` with two components and a bitdepth of 8 for each.
  211. .. _class_Image_constant_FORMAT_RGB8:
  212. .. rst-class:: classref-enumeration-constant
  213. :ref:`Format<enum_Image_Format>` **FORMAT_RGB8** = ``4``
  214. OpenGL texture format ``RGB`` with three components, each with a bitdepth of 8.
  215. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, a nonlinear sRGB to linear encoding conversion is performed.
  216. .. _class_Image_constant_FORMAT_RGBA8:
  217. .. rst-class:: classref-enumeration-constant
  218. :ref:`Format<enum_Image_Format>` **FORMAT_RGBA8** = ``5``
  219. OpenGL texture format ``RGBA`` with four components, each with a bitdepth of 8.
  220. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, a nonlinear sRGB to linear encoding conversion is performed.
  221. .. _class_Image_constant_FORMAT_RGBA4444:
  222. .. rst-class:: classref-enumeration-constant
  223. :ref:`Format<enum_Image_Format>` **FORMAT_RGBA4444** = ``6``
  224. OpenGL texture format ``RGBA`` with four components, each with a bitdepth of 4.
  225. .. _class_Image_constant_FORMAT_RGB565:
  226. .. rst-class:: classref-enumeration-constant
  227. :ref:`Format<enum_Image_Format>` **FORMAT_RGB565** = ``7``
  228. OpenGL texture format ``RGB`` with three components. Red and blue have a bitdepth of 5, and green has a bitdepth of 6.
  229. .. _class_Image_constant_FORMAT_RF:
  230. .. rst-class:: classref-enumeration-constant
  231. :ref:`Format<enum_Image_Format>` **FORMAT_RF** = ``8``
  232. OpenGL texture format ``GL_R32F`` where there's one component, a 32-bit floating-point value.
  233. .. _class_Image_constant_FORMAT_RGF:
  234. .. rst-class:: classref-enumeration-constant
  235. :ref:`Format<enum_Image_Format>` **FORMAT_RGF** = ``9``
  236. OpenGL texture format ``GL_RG32F`` where there are two components, each a 32-bit floating-point values.
  237. .. _class_Image_constant_FORMAT_RGBF:
  238. .. rst-class:: classref-enumeration-constant
  239. :ref:`Format<enum_Image_Format>` **FORMAT_RGBF** = ``10``
  240. OpenGL texture format ``GL_RGB32F`` where there are three components, each a 32-bit floating-point values.
  241. .. _class_Image_constant_FORMAT_RGBAF:
  242. .. rst-class:: classref-enumeration-constant
  243. :ref:`Format<enum_Image_Format>` **FORMAT_RGBAF** = ``11``
  244. OpenGL texture format ``GL_RGBA32F`` where there are four components, each a 32-bit floating-point values.
  245. .. _class_Image_constant_FORMAT_RH:
  246. .. rst-class:: classref-enumeration-constant
  247. :ref:`Format<enum_Image_Format>` **FORMAT_RH** = ``12``
  248. OpenGL texture format ``GL_R16F`` where there's one component, a 16-bit "half-precision" floating-point value.
  249. .. _class_Image_constant_FORMAT_RGH:
  250. .. rst-class:: classref-enumeration-constant
  251. :ref:`Format<enum_Image_Format>` **FORMAT_RGH** = ``13``
  252. OpenGL texture format ``GL_RG16F`` where there are two components, each a 16-bit "half-precision" floating-point value.
  253. .. _class_Image_constant_FORMAT_RGBH:
  254. .. rst-class:: classref-enumeration-constant
  255. :ref:`Format<enum_Image_Format>` **FORMAT_RGBH** = ``14``
  256. OpenGL texture format ``GL_RGB16F`` where there are three components, each a 16-bit "half-precision" floating-point value.
  257. .. _class_Image_constant_FORMAT_RGBAH:
  258. .. rst-class:: classref-enumeration-constant
  259. :ref:`Format<enum_Image_Format>` **FORMAT_RGBAH** = ``15``
  260. OpenGL texture format ``GL_RGBA16F`` where there are four components, each a 16-bit "half-precision" floating-point value.
  261. .. _class_Image_constant_FORMAT_RGBE9995:
  262. .. rst-class:: classref-enumeration-constant
  263. :ref:`Format<enum_Image_Format>` **FORMAT_RGBE9995** = ``16``
  264. A special OpenGL texture format where the three color components have 9 bits of precision and all three share a single 5-bit exponent.
  265. .. _class_Image_constant_FORMAT_DXT1:
  266. .. rst-class:: classref-enumeration-constant
  267. :ref:`Format<enum_Image_Format>` **FORMAT_DXT1** = ``17``
  268. 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.
  269. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, a nonlinear sRGB to linear encoding conversion is performed.
  270. .. _class_Image_constant_FORMAT_DXT3:
  271. .. rst-class:: classref-enumeration-constant
  272. :ref:`Format<enum_Image_Format>` **FORMAT_DXT3** = ``18``
  273. 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.
  274. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, a nonlinear sRGB to linear encoding conversion is performed.
  275. .. _class_Image_constant_FORMAT_DXT5:
  276. .. rst-class:: classref-enumeration-constant
  277. :ref:`Format<enum_Image_Format>` **FORMAT_DXT5** = ``19``
  278. 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.
  279. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, a nonlinear sRGB to linear encoding conversion is performed.
  280. .. _class_Image_constant_FORMAT_RGTC_R:
  281. .. rst-class:: classref-enumeration-constant
  282. :ref:`Format<enum_Image_Format>` **FORMAT_RGTC_R** = ``20``
  283. 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.
  284. .. _class_Image_constant_FORMAT_RGTC_RG:
  285. .. rst-class:: classref-enumeration-constant
  286. :ref:`Format<enum_Image_Format>` **FORMAT_RGTC_RG** = ``21``
  287. 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.
  288. .. _class_Image_constant_FORMAT_BPTC_RGBA:
  289. .. rst-class:: classref-enumeration-constant
  290. :ref:`Format<enum_Image_Format>` **FORMAT_BPTC_RGBA** = ``22``
  291. Texture format that uses `BPTC <https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression>`__ compression with unsigned normalized RGBA components.
  292. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, a nonlinear sRGB to linear encoding conversion is performed.
  293. .. _class_Image_constant_FORMAT_BPTC_RGBF:
  294. .. rst-class:: classref-enumeration-constant
  295. :ref:`Format<enum_Image_Format>` **FORMAT_BPTC_RGBF** = ``23``
  296. Texture format that uses `BPTC <https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression>`__ compression with signed floating-point RGB components.
  297. .. _class_Image_constant_FORMAT_BPTC_RGBFU:
  298. .. rst-class:: classref-enumeration-constant
  299. :ref:`Format<enum_Image_Format>` **FORMAT_BPTC_RGBFU** = ``24``
  300. Texture format that uses `BPTC <https://www.khronos.org/opengl/wiki/BPTC_Texture_Compression>`__ compression with unsigned floating-point RGB components.
  301. .. _class_Image_constant_FORMAT_ETC:
  302. .. rst-class:: classref-enumeration-constant
  303. :ref:`Format<enum_Image_Format>` **FORMAT_ETC** = ``25``
  304. `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.
  305. .. _class_Image_constant_FORMAT_ETC2_R11:
  306. .. rst-class:: classref-enumeration-constant
  307. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_R11** = ``26``
  308. `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.
  309. .. _class_Image_constant_FORMAT_ETC2_R11S:
  310. .. rst-class:: classref-enumeration-constant
  311. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_R11S** = ``27``
  312. `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.
  313. .. _class_Image_constant_FORMAT_ETC2_RG11:
  314. .. rst-class:: classref-enumeration-constant
  315. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RG11** = ``28``
  316. `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.
  317. .. _class_Image_constant_FORMAT_ETC2_RG11S:
  318. .. rst-class:: classref-enumeration-constant
  319. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RG11S** = ``29``
  320. `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.
  321. .. _class_Image_constant_FORMAT_ETC2_RGB8:
  322. .. rst-class:: classref-enumeration-constant
  323. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RGB8** = ``30``
  324. `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.
  325. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, a nonlinear sRGB to linear encoding conversion is performed.
  326. .. _class_Image_constant_FORMAT_ETC2_RGBA8:
  327. .. rst-class:: classref-enumeration-constant
  328. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RGBA8** = ``31``
  329. `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.
  330. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, a nonlinear sRGB to linear encoding conversion is performed.
  331. .. _class_Image_constant_FORMAT_ETC2_RGB8A1:
  332. .. rst-class:: classref-enumeration-constant
  333. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RGB8A1** = ``32``
  334. `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.
  335. \ **Note:** When creating an :ref:`ImageTexture<class_ImageTexture>`, a nonlinear sRGB to linear encoding conversion is performed.
  336. .. _class_Image_constant_FORMAT_ETC2_RA_AS_RG:
  337. .. rst-class:: classref-enumeration-constant
  338. :ref:`Format<enum_Image_Format>` **FORMAT_ETC2_RA_AS_RG** = ``33``
  339. `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>`.
  340. .. _class_Image_constant_FORMAT_DXT5_RA_AS_RG:
  341. .. rst-class:: classref-enumeration-constant
  342. :ref:`Format<enum_Image_Format>` **FORMAT_DXT5_RA_AS_RG** = ``34``
  343. 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>`.
  344. .. _class_Image_constant_FORMAT_ASTC_4x4:
  345. .. rst-class:: classref-enumeration-constant
  346. :ref:`Format<enum_Image_Format>` **FORMAT_ASTC_4x4** = ``35``
  347. `Adaptive Scalable Texture Compression <https://en.wikipedia.org/wiki/Adaptive_scalable_texture_compression>`__. This implements the 4×4 (high quality) mode.
  348. .. _class_Image_constant_FORMAT_ASTC_4x4_HDR:
  349. .. rst-class:: classref-enumeration-constant
  350. :ref:`Format<enum_Image_Format>` **FORMAT_ASTC_4x4_HDR** = ``36``
  351. 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.
  352. .. _class_Image_constant_FORMAT_ASTC_8x8:
  353. .. rst-class:: classref-enumeration-constant
  354. :ref:`Format<enum_Image_Format>` **FORMAT_ASTC_8x8** = ``37``
  355. `Adaptive Scalable Texture Compression <https://en.wikipedia.org/wiki/Adaptive_scalable_texture_compression>`__. This implements the 8×8 (low quality) mode.
  356. .. _class_Image_constant_FORMAT_ASTC_8x8_HDR:
  357. .. rst-class:: classref-enumeration-constant
  358. :ref:`Format<enum_Image_Format>` **FORMAT_ASTC_8x8_HDR** = ``38``
  359. 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.
  360. .. _class_Image_constant_FORMAT_R16:
  361. .. rst-class:: classref-enumeration-constant
  362. :ref:`Format<enum_Image_Format>` **FORMAT_R16** = ``39``
  363. OpenGL texture format ``GL_R16`` where there's one component, a 16-bit unsigned normalized integer value. Since the value is normalized, each component is clamped between ``0.0`` and ``1.0`` (inclusive).
  364. \ **Note:** Due to limited hardware support, it is mainly recommended to be used on desktop or console devices. It may be unsupported on mobile or web, and will consequently be converted to :ref:`FORMAT_RF<class_Image_constant_FORMAT_RF>`.
  365. .. _class_Image_constant_FORMAT_RG16:
  366. .. rst-class:: classref-enumeration-constant
  367. :ref:`Format<enum_Image_Format>` **FORMAT_RG16** = ``40``
  368. OpenGL texture format ``GL_RG16`` where there are two components, each a 16-bit unsigned normalized integer value. Since the value is normalized, each component is clamped between ``0.0`` and ``1.0`` (inclusive).
  369. \ **Note:** Due to limited hardware support, it is mainly recommended to be used on desktop or console devices. It may be unsupported on mobile or web, and will consequently be converted to :ref:`FORMAT_RGF<class_Image_constant_FORMAT_RGF>`.
  370. .. _class_Image_constant_FORMAT_RGB16:
  371. .. rst-class:: classref-enumeration-constant
  372. :ref:`Format<enum_Image_Format>` **FORMAT_RGB16** = ``41``
  373. OpenGL texture format ``GL_RGB16`` where there are three components, each a 16-bit unsigned normalized integer value. Since the value is normalized, each component is clamped between ``0.0`` and ``1.0`` (inclusive).
  374. \ **Note:** Due to limited hardware support, it is mainly recommended to be used on desktop or console devices. It may be unsupported on mobile or web, and will consequently be converted to :ref:`FORMAT_RGBF<class_Image_constant_FORMAT_RGBF>`.
  375. .. _class_Image_constant_FORMAT_RGBA16:
  376. .. rst-class:: classref-enumeration-constant
  377. :ref:`Format<enum_Image_Format>` **FORMAT_RGBA16** = ``42``
  378. OpenGL texture format ``GL_RGBA16`` where there are four components, each a 16-bit unsigned normalized integer value. Since the value is normalized, each component is clamped between ``0.0`` and ``1.0`` (inclusive).
  379. \ **Note:** Due to limited hardware support, it is mainly recommended to be used on desktop or console devices. It may be unsupported on mobile or web, and will consequently be converted to :ref:`FORMAT_RGBAF<class_Image_constant_FORMAT_RGBAF>`.
  380. .. _class_Image_constant_FORMAT_R16I:
  381. .. rst-class:: classref-enumeration-constant
  382. :ref:`Format<enum_Image_Format>` **FORMAT_R16I** = ``43``
  383. OpenGL texture format ``GL_R16UI`` where there's one component, a 16-bit unsigned integer value. Each component is clamped between ``0`` and ``65535`` (inclusive).
  384. \ **Note:** When used in a shader, the texture requires usage of ``usampler`` samplers. Additionally, it only supports nearest-neighbor filtering under the Compatibility renderer.
  385. \ **Note:** When sampling using :ref:`get_pixel()<class_Image_method_get_pixel>`, returned :ref:`Color<class_Color>`\ s have to be divided by ``65535`` to get the correct color value.
  386. .. _class_Image_constant_FORMAT_RG16I:
  387. .. rst-class:: classref-enumeration-constant
  388. :ref:`Format<enum_Image_Format>` **FORMAT_RG16I** = ``44``
  389. OpenGL texture format ``GL_RG16UI`` where there are two components, each a 16-bit unsigned integer value. Each component is clamped between ``0`` and ``65535`` (inclusive).
  390. \ **Note:** When used in a shader, the texture requires usage of ``usampler`` samplers. Additionally, it only supports nearest-neighbor filtering under the Compatibility renderer.
  391. \ **Note:** When sampling using :ref:`get_pixel()<class_Image_method_get_pixel>`, returned :ref:`Color<class_Color>`\ s have to be divided by ``65535`` to get the correct color value.
  392. .. _class_Image_constant_FORMAT_RGB16I:
  393. .. rst-class:: classref-enumeration-constant
  394. :ref:`Format<enum_Image_Format>` **FORMAT_RGB16I** = ``45``
  395. OpenGL texture format ``GL_RGB16UI`` where there are three components, each a 16-bit unsigned integer value. Each component is clamped between ``0`` and ``65535`` (inclusive).
  396. \ **Note:** When used in a shader, the texture requires usage of ``usampler`` samplers. Additionally, it only supports nearest-neighbor filtering under the Compatibility renderer.
  397. \ **Note:** When sampling using :ref:`get_pixel()<class_Image_method_get_pixel>`, returned :ref:`Color<class_Color>`\ s have to be divided by ``65535`` to get the correct color value.
  398. .. _class_Image_constant_FORMAT_RGBA16I:
  399. .. rst-class:: classref-enumeration-constant
  400. :ref:`Format<enum_Image_Format>` **FORMAT_RGBA16I** = ``46``
  401. OpenGL texture format ``GL_RGBA16UI`` where there are four components, each a 16-bit unsigned integer value. Each component is clamped between ``0`` and ``65535`` (inclusive).
  402. \ **Note:** When used in a shader, the texture requires usage of ``usampler`` samplers. Additionally, it only supports nearest-neighbor filtering under the Compatibility renderer.
  403. \ **Note:** When sampling using :ref:`get_pixel()<class_Image_method_get_pixel>`, returned :ref:`Color<class_Color>`\ s have to be divided by ``65535`` to get the correct color value.
  404. .. _class_Image_constant_FORMAT_MAX:
  405. .. rst-class:: classref-enumeration-constant
  406. :ref:`Format<enum_Image_Format>` **FORMAT_MAX** = ``47``
  407. Represents the size of the :ref:`Format<enum_Image_Format>` enum.
  408. .. rst-class:: classref-item-separator
  409. ----
  410. .. _enum_Image_Interpolation:
  411. .. rst-class:: classref-enumeration
  412. enum **Interpolation**: :ref:`🔗<enum_Image_Interpolation>`
  413. .. _class_Image_constant_INTERPOLATE_NEAREST:
  414. .. rst-class:: classref-enumeration-constant
  415. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_NEAREST** = ``0``
  416. Performs nearest-neighbor interpolation. If the image is resized, it will be pixelated.
  417. .. _class_Image_constant_INTERPOLATE_BILINEAR:
  418. .. rst-class:: classref-enumeration-constant
  419. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_BILINEAR** = ``1``
  420. 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.
  421. .. _class_Image_constant_INTERPOLATE_CUBIC:
  422. .. rst-class:: classref-enumeration-constant
  423. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_CUBIC** = ``2``
  424. 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.
  425. .. _class_Image_constant_INTERPOLATE_TRILINEAR:
  426. .. rst-class:: classref-enumeration-constant
  427. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_TRILINEAR** = ``3``
  428. Performs bilinear separately on the two most-suited mipmap levels, then linearly interpolates between them.
  429. It's slower than :ref:`INTERPOLATE_BILINEAR<class_Image_constant_INTERPOLATE_BILINEAR>`, but produces higher-quality results with far fewer aliasing artifacts.
  430. If the image does not have mipmaps, they will be generated and used internally, but no mipmaps will be generated on the resulting image.
  431. \ **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.
  432. 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.
  433. .. _class_Image_constant_INTERPOLATE_LANCZOS:
  434. .. rst-class:: classref-enumeration-constant
  435. :ref:`Interpolation<enum_Image_Interpolation>` **INTERPOLATE_LANCZOS** = ``4``
  436. Performs Lanczos interpolation. This is the slowest image resizing mode, but it typically gives the best results, especially when downscaling images.
  437. .. rst-class:: classref-item-separator
  438. ----
  439. .. _enum_Image_AlphaMode:
  440. .. rst-class:: classref-enumeration
  441. enum **AlphaMode**: :ref:`🔗<enum_Image_AlphaMode>`
  442. .. _class_Image_constant_ALPHA_NONE:
  443. .. rst-class:: classref-enumeration-constant
  444. :ref:`AlphaMode<enum_Image_AlphaMode>` **ALPHA_NONE** = ``0``
  445. Image is fully opaque. It does not store alpha data.
  446. .. _class_Image_constant_ALPHA_BIT:
  447. .. rst-class:: classref-enumeration-constant
  448. :ref:`AlphaMode<enum_Image_AlphaMode>` **ALPHA_BIT** = ``1``
  449. Image stores either fully opaque or fully transparent pixels. Also known as punchthrough alpha.
  450. .. _class_Image_constant_ALPHA_BLEND:
  451. .. rst-class:: classref-enumeration-constant
  452. :ref:`AlphaMode<enum_Image_AlphaMode>` **ALPHA_BLEND** = ``2``
  453. Image stores alpha data with values varying between ``0.0`` and ``1.0``.
  454. .. rst-class:: classref-item-separator
  455. ----
  456. .. _enum_Image_CompressMode:
  457. .. rst-class:: classref-enumeration
  458. enum **CompressMode**: :ref:`🔗<enum_Image_CompressMode>`
  459. .. _class_Image_constant_COMPRESS_S3TC:
  460. .. rst-class:: classref-enumeration-constant
  461. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_S3TC** = ``0``
  462. Use S3TC compression.
  463. .. _class_Image_constant_COMPRESS_ETC:
  464. .. rst-class:: classref-enumeration-constant
  465. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_ETC** = ``1``
  466. Use ETC compression.
  467. .. _class_Image_constant_COMPRESS_ETC2:
  468. .. rst-class:: classref-enumeration-constant
  469. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_ETC2** = ``2``
  470. Use ETC2 compression.
  471. .. _class_Image_constant_COMPRESS_BPTC:
  472. .. rst-class:: classref-enumeration-constant
  473. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_BPTC** = ``3``
  474. Use BPTC compression.
  475. .. _class_Image_constant_COMPRESS_ASTC:
  476. .. rst-class:: classref-enumeration-constant
  477. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_ASTC** = ``4``
  478. Use ASTC compression.
  479. .. _class_Image_constant_COMPRESS_MAX:
  480. .. rst-class:: classref-enumeration-constant
  481. :ref:`CompressMode<enum_Image_CompressMode>` **COMPRESS_MAX** = ``5``
  482. Represents the size of the :ref:`CompressMode<enum_Image_CompressMode>` enum.
  483. .. rst-class:: classref-item-separator
  484. ----
  485. .. _enum_Image_UsedChannels:
  486. .. rst-class:: classref-enumeration
  487. enum **UsedChannels**: :ref:`🔗<enum_Image_UsedChannels>`
  488. .. _class_Image_constant_USED_CHANNELS_L:
  489. .. rst-class:: classref-enumeration-constant
  490. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_L** = ``0``
  491. The image only uses one channel for luminance (grayscale).
  492. .. _class_Image_constant_USED_CHANNELS_LA:
  493. .. rst-class:: classref-enumeration-constant
  494. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_LA** = ``1``
  495. The image uses two channels for luminance and alpha, respectively.
  496. .. _class_Image_constant_USED_CHANNELS_R:
  497. .. rst-class:: classref-enumeration-constant
  498. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_R** = ``2``
  499. The image only uses the red channel.
  500. .. _class_Image_constant_USED_CHANNELS_RG:
  501. .. rst-class:: classref-enumeration-constant
  502. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_RG** = ``3``
  503. The image uses two channels for red and green.
  504. .. _class_Image_constant_USED_CHANNELS_RGB:
  505. .. rst-class:: classref-enumeration-constant
  506. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_RGB** = ``4``
  507. The image uses three channels for red, green, and blue.
  508. .. _class_Image_constant_USED_CHANNELS_RGBA:
  509. .. rst-class:: classref-enumeration-constant
  510. :ref:`UsedChannels<enum_Image_UsedChannels>` **USED_CHANNELS_RGBA** = ``5``
  511. The image uses four channels for red, green, blue, and alpha.
  512. .. rst-class:: classref-item-separator
  513. ----
  514. .. _enum_Image_CompressSource:
  515. .. rst-class:: classref-enumeration
  516. enum **CompressSource**: :ref:`🔗<enum_Image_CompressSource>`
  517. .. _class_Image_constant_COMPRESS_SOURCE_GENERIC:
  518. .. rst-class:: classref-enumeration-constant
  519. :ref:`CompressSource<enum_Image_CompressSource>` **COMPRESS_SOURCE_GENERIC** = ``0``
  520. Source texture (before compression) is a regular texture. Default for all textures.
  521. .. _class_Image_constant_COMPRESS_SOURCE_SRGB:
  522. .. rst-class:: classref-enumeration-constant
  523. :ref:`CompressSource<enum_Image_CompressSource>` **COMPRESS_SOURCE_SRGB** = ``1``
  524. Source texture (before compression) uses nonlinear sRGB encoding.
  525. .. _class_Image_constant_COMPRESS_SOURCE_NORMAL:
  526. .. rst-class:: classref-enumeration-constant
  527. :ref:`CompressSource<enum_Image_CompressSource>` **COMPRESS_SOURCE_NORMAL** = ``2``
  528. Source texture (before compression) is a normal texture (e.g. it can be compressed into two channels).
  529. .. rst-class:: classref-item-separator
  530. ----
  531. .. _enum_Image_ASTCFormat:
  532. .. rst-class:: classref-enumeration
  533. enum **ASTCFormat**: :ref:`🔗<enum_Image_ASTCFormat>`
  534. .. _class_Image_constant_ASTC_FORMAT_4x4:
  535. .. rst-class:: classref-enumeration-constant
  536. :ref:`ASTCFormat<enum_Image_ASTCFormat>` **ASTC_FORMAT_4x4** = ``0``
  537. Hint to indicate that the high quality 4×4 ASTC compression format should be used.
  538. .. _class_Image_constant_ASTC_FORMAT_8x8:
  539. .. rst-class:: classref-enumeration-constant
  540. :ref:`ASTCFormat<enum_Image_ASTCFormat>` **ASTC_FORMAT_8x8** = ``1``
  541. Hint to indicate that the low quality 8×8 ASTC compression format should be used.
  542. .. rst-class:: classref-section-separator
  543. ----
  544. .. rst-class:: classref-descriptions-group
  545. Constants
  546. ---------
  547. .. _class_Image_constant_MAX_WIDTH:
  548. .. rst-class:: classref-constant
  549. **MAX_WIDTH** = ``16777216`` :ref:`🔗<class_Image_constant_MAX_WIDTH>`
  550. The maximal width allowed for **Image** resources.
  551. .. _class_Image_constant_MAX_HEIGHT:
  552. .. rst-class:: classref-constant
  553. **MAX_HEIGHT** = ``16777216`` :ref:`🔗<class_Image_constant_MAX_HEIGHT>`
  554. The maximal height allowed for **Image** resources.
  555. .. rst-class:: classref-section-separator
  556. ----
  557. .. rst-class:: classref-descriptions-group
  558. Property Descriptions
  559. ---------------------
  560. .. _class_Image_property_data:
  561. .. rst-class:: classref-property
  562. :ref:`Dictionary<class_Dictionary>` **data** = ``{ "data": PackedByteArray(), "format": "Lum8", "height": 0, "mipmaps": false, "width": 0 }`` :ref:`🔗<class_Image_property_data>`
  563. Holds all the image's color data in a given format. See :ref:`Format<enum_Image_Format>` constants.
  564. .. rst-class:: classref-section-separator
  565. ----
  566. .. rst-class:: classref-descriptions-group
  567. Method Descriptions
  568. -------------------
  569. .. _class_Image_method_adjust_bcs:
  570. .. rst-class:: classref-method
  571. |void| **adjust_bcs**\ (\ brightness\: :ref:`float<class_float>`, contrast\: :ref:`float<class_float>`, saturation\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Image_method_adjust_bcs>`
  572. 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>`).
  573. .. rst-class:: classref-item-separator
  574. ----
  575. .. _class_Image_method_blend_rect:
  576. .. rst-class:: classref-method
  577. |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>`
  578. 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.
  579. .. rst-class:: classref-item-separator
  580. ----
  581. .. _class_Image_method_blend_rect_mask:
  582. .. rst-class:: classref-method
  583. |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>`
  584. 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.
  585. .. rst-class:: classref-item-separator
  586. ----
  587. .. _class_Image_method_blit_rect:
  588. .. rst-class:: classref-method
  589. |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>`
  590. 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.
  591. \ **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.
  592. .. rst-class:: classref-item-separator
  593. ----
  594. .. _class_Image_method_blit_rect_mask:
  595. .. rst-class:: classref-method
  596. |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>`
  597. 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.
  598. .. rst-class:: classref-item-separator
  599. ----
  600. .. _class_Image_method_bump_map_to_normal_map:
  601. .. rst-class:: classref-method
  602. |void| **bump_map_to_normal_map**\ (\ bump_scale\: :ref:`float<class_float>` = 1.0\ ) :ref:`🔗<class_Image_method_bump_map_to_normal_map>`
  603. 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.
  604. .. rst-class:: classref-item-separator
  605. ----
  606. .. _class_Image_method_clear_mipmaps:
  607. .. rst-class:: classref-method
  608. |void| **clear_mipmaps**\ (\ ) :ref:`🔗<class_Image_method_clear_mipmaps>`
  609. Removes the image's mipmaps.
  610. .. rst-class:: classref-item-separator
  611. ----
  612. .. _class_Image_method_compress:
  613. .. rst-class:: classref-method
  614. :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>`
  615. Compresses the image with a VRAM-compressed format 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.
  616. The ``source`` parameter helps to pick the best compression method for DXT and ETC2 formats. It is ignored for ASTC compression.
  617. The ``astc_format`` parameter is only taken into account when using ASTC compression; it is ignored for all other formats.
  618. \ **Note:** :ref:`compress()<class_Image_method_compress>` is only supported in editor builds. When run in an exported project, this method always returns :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>`.
  619. .. rst-class:: classref-item-separator
  620. ----
  621. .. _class_Image_method_compress_from_channels:
  622. .. rst-class:: classref-method
  623. :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>`
  624. Compresses the image with a VRAM-compressed format 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.
  625. 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.
  626. The ``astc_format`` parameter is only taken into account when using ASTC compression; it is ignored for all other formats.
  627. \ **Note:** :ref:`compress_from_channels()<class_Image_method_compress_from_channels>` is only supported in editor builds. When run in an exported project, this method always returns :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>`.
  628. .. rst-class:: classref-item-separator
  629. ----
  630. .. _class_Image_method_compute_image_metrics:
  631. .. rst-class:: classref-method
  632. :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>`
  633. Compute image metrics on the current image and the compared image. This can be used to calculate the similarity between two images.
  634. The dictionary contains ``max``, ``mean``, ``mean_squared``, ``root_mean_squared`` and ``peak_snr``.
  635. .. rst-class:: classref-item-separator
  636. ----
  637. .. _class_Image_method_convert:
  638. .. rst-class:: classref-method
  639. |void| **convert**\ (\ format\: :ref:`Format<enum_Image_Format>`\ ) :ref:`🔗<class_Image_method_convert>`
  640. Converts this image's format to the given ``format``.
  641. .. rst-class:: classref-item-separator
  642. ----
  643. .. _class_Image_method_copy_from:
  644. .. rst-class:: classref-method
  645. |void| **copy_from**\ (\ src\: :ref:`Image<class_Image>`\ ) :ref:`🔗<class_Image_method_copy_from>`
  646. Copies ``src`` image to this image.
  647. .. rst-class:: classref-item-separator
  648. ----
  649. .. _class_Image_method_create:
  650. .. rst-class:: classref-method
  651. :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>`
  652. **Deprecated:** Use :ref:`create_empty()<class_Image_method_create_empty>`.
  653. Creates an empty image of the given size and format. If ``use_mipmaps`` is ``true``, generates mipmaps for this image. See the :ref:`generate_mipmaps()<class_Image_method_generate_mipmaps>`.
  654. .. rst-class:: classref-item-separator
  655. ----
  656. .. _class_Image_method_create_empty:
  657. .. rst-class:: classref-method
  658. :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>`
  659. Creates an empty image of the given size and format. If ``use_mipmaps`` is ``true``, generates mipmaps for this image. See the :ref:`generate_mipmaps()<class_Image_method_generate_mipmaps>`.
  660. .. rst-class:: classref-item-separator
  661. ----
  662. .. _class_Image_method_create_from_data:
  663. .. rst-class:: classref-method
  664. :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>`
  665. Creates a new image of the given size and format. Fills the image with the given raw data. If ``use_mipmaps`` is ``true``, loads the mipmaps for this image from ``data``. See :ref:`generate_mipmaps()<class_Image_method_generate_mipmaps>`.
  666. .. rst-class:: classref-item-separator
  667. ----
  668. .. _class_Image_method_crop:
  669. .. rst-class:: classref-method
  670. |void| **crop**\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Image_method_crop>`
  671. 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.
  672. .. rst-class:: classref-item-separator
  673. ----
  674. .. _class_Image_method_decompress:
  675. .. rst-class:: classref-method
  676. :ref:`Error<enum_@GlobalScope_Error>` **decompress**\ (\ ) :ref:`🔗<class_Image_method_decompress>`
  677. Decompresses the image if it is VRAM-compressed in a supported format. This increases memory utilization, but allows modifying the image. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` if the format is supported, otherwise :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>`. All VRAM-compressed formats supported by Godot can be decompressed with this method, except :ref:`FORMAT_ETC2_R11S<class_Image_constant_FORMAT_ETC2_R11S>`, :ref:`FORMAT_ETC2_RG11S<class_Image_constant_FORMAT_ETC2_RG11S>`, and :ref:`FORMAT_ETC2_RGB8A1<class_Image_constant_FORMAT_ETC2_RGB8A1>`.
  678. .. rst-class:: classref-item-separator
  679. ----
  680. .. _class_Image_method_detect_alpha:
  681. .. rst-class:: classref-method
  682. :ref:`AlphaMode<enum_Image_AlphaMode>` **detect_alpha**\ (\ ) |const| :ref:`🔗<class_Image_method_detect_alpha>`
  683. 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.
  684. .. rst-class:: classref-item-separator
  685. ----
  686. .. _class_Image_method_detect_used_channels:
  687. .. rst-class:: classref-method
  688. :ref:`UsedChannels<enum_Image_UsedChannels>` **detect_used_channels**\ (\ source\: :ref:`CompressSource<enum_Image_CompressSource>` = 0\ ) |const| :ref:`🔗<class_Image_method_detect_used_channels>`
  689. Returns the color channels used by this image. If the image is compressed, the original ``source`` must be specified.
  690. .. rst-class:: classref-item-separator
  691. ----
  692. .. _class_Image_method_fill:
  693. .. rst-class:: classref-method
  694. |void| **fill**\ (\ color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_Image_method_fill>`
  695. Fills the image with ``color``.
  696. .. rst-class:: classref-item-separator
  697. ----
  698. .. _class_Image_method_fill_rect:
  699. .. rst-class:: classref-method
  700. |void| **fill_rect**\ (\ rect\: :ref:`Rect2i<class_Rect2i>`, color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_Image_method_fill_rect>`
  701. Fills ``rect`` with ``color``.
  702. .. rst-class:: classref-item-separator
  703. ----
  704. .. _class_Image_method_fix_alpha_edges:
  705. .. rst-class:: classref-method
  706. |void| **fix_alpha_edges**\ (\ ) :ref:`🔗<class_Image_method_fix_alpha_edges>`
  707. Blends low-alpha pixels with nearby pixels.
  708. .. rst-class:: classref-item-separator
  709. ----
  710. .. _class_Image_method_flip_x:
  711. .. rst-class:: classref-method
  712. |void| **flip_x**\ (\ ) :ref:`🔗<class_Image_method_flip_x>`
  713. Flips the image horizontally.
  714. .. rst-class:: classref-item-separator
  715. ----
  716. .. _class_Image_method_flip_y:
  717. .. rst-class:: classref-method
  718. |void| **flip_y**\ (\ ) :ref:`🔗<class_Image_method_flip_y>`
  719. Flips the image vertically.
  720. .. rst-class:: classref-item-separator
  721. ----
  722. .. _class_Image_method_generate_mipmaps:
  723. .. rst-class:: classref-method
  724. :ref:`Error<enum_@GlobalScope_Error>` **generate_mipmaps**\ (\ renormalize\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_Image_method_generate_mipmaps>`
  725. 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.
  726. 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.
  727. .. rst-class:: classref-item-separator
  728. ----
  729. .. _class_Image_method_get_data:
  730. .. rst-class:: classref-method
  731. :ref:`PackedByteArray<class_PackedByteArray>` **get_data**\ (\ ) |const| :ref:`🔗<class_Image_method_get_data>`
  732. Returns a copy of the image's raw data.
  733. .. rst-class:: classref-item-separator
  734. ----
  735. .. _class_Image_method_get_data_size:
  736. .. rst-class:: classref-method
  737. :ref:`int<class_int>` **get_data_size**\ (\ ) |const| :ref:`🔗<class_Image_method_get_data_size>`
  738. Returns size (in bytes) of the image's raw data.
  739. .. rst-class:: classref-item-separator
  740. ----
  741. .. _class_Image_method_get_format:
  742. .. rst-class:: classref-method
  743. :ref:`Format<enum_Image_Format>` **get_format**\ (\ ) |const| :ref:`🔗<class_Image_method_get_format>`
  744. Returns this image's format.
  745. .. rst-class:: classref-item-separator
  746. ----
  747. .. _class_Image_method_get_height:
  748. .. rst-class:: classref-method
  749. :ref:`int<class_int>` **get_height**\ (\ ) |const| :ref:`🔗<class_Image_method_get_height>`
  750. Returns the image's height.
  751. .. rst-class:: classref-item-separator
  752. ----
  753. .. _class_Image_method_get_mipmap_count:
  754. .. rst-class:: classref-method
  755. :ref:`int<class_int>` **get_mipmap_count**\ (\ ) |const| :ref:`🔗<class_Image_method_get_mipmap_count>`
  756. 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.
  757. .. rst-class:: classref-item-separator
  758. ----
  759. .. _class_Image_method_get_mipmap_offset:
  760. .. rst-class:: classref-method
  761. :ref:`int<class_int>` **get_mipmap_offset**\ (\ mipmap\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_Image_method_get_mipmap_offset>`
  762. Returns the offset where the image's mipmap with index ``mipmap`` is stored in the :ref:`data<class_Image_property_data>` dictionary.
  763. .. rst-class:: classref-item-separator
  764. ----
  765. .. _class_Image_method_get_pixel:
  766. .. rst-class:: classref-method
  767. :ref:`Color<class_Color>` **get_pixel**\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_Image_method_get_pixel>`
  768. Returns the color of the pixel at ``(x, y)``.
  769. 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.
  770. .. rst-class:: classref-item-separator
  771. ----
  772. .. _class_Image_method_get_pixelv:
  773. .. rst-class:: classref-method
  774. :ref:`Color<class_Color>` **get_pixelv**\ (\ point\: :ref:`Vector2i<class_Vector2i>`\ ) |const| :ref:`🔗<class_Image_method_get_pixelv>`
  775. Returns the color of the pixel at ``point``.
  776. 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.
  777. .. rst-class:: classref-item-separator
  778. ----
  779. .. _class_Image_method_get_region:
  780. .. rst-class:: classref-method
  781. :ref:`Image<class_Image>` **get_region**\ (\ region\: :ref:`Rect2i<class_Rect2i>`\ ) |const| :ref:`🔗<class_Image_method_get_region>`
  782. Returns a new **Image** that is a copy of this **Image**'s area specified with ``region``.
  783. .. rst-class:: classref-item-separator
  784. ----
  785. .. _class_Image_method_get_size:
  786. .. rst-class:: classref-method
  787. :ref:`Vector2i<class_Vector2i>` **get_size**\ (\ ) |const| :ref:`🔗<class_Image_method_get_size>`
  788. Returns the image's size (width and height).
  789. .. rst-class:: classref-item-separator
  790. ----
  791. .. _class_Image_method_get_used_rect:
  792. .. rst-class:: classref-method
  793. :ref:`Rect2i<class_Rect2i>` **get_used_rect**\ (\ ) |const| :ref:`🔗<class_Image_method_get_used_rect>`
  794. Returns a :ref:`Rect2i<class_Rect2i>` enclosing the visible portion of the image, considering each pixel with a non-zero alpha channel as visible.
  795. .. rst-class:: classref-item-separator
  796. ----
  797. .. _class_Image_method_get_width:
  798. .. rst-class:: classref-method
  799. :ref:`int<class_int>` **get_width**\ (\ ) |const| :ref:`🔗<class_Image_method_get_width>`
  800. Returns the image's width.
  801. .. rst-class:: classref-item-separator
  802. ----
  803. .. _class_Image_method_has_mipmaps:
  804. .. rst-class:: classref-method
  805. :ref:`bool<class_bool>` **has_mipmaps**\ (\ ) |const| :ref:`🔗<class_Image_method_has_mipmaps>`
  806. Returns ``true`` if the image has generated mipmaps.
  807. .. rst-class:: classref-item-separator
  808. ----
  809. .. _class_Image_method_is_compressed:
  810. .. rst-class:: classref-method
  811. :ref:`bool<class_bool>` **is_compressed**\ (\ ) |const| :ref:`🔗<class_Image_method_is_compressed>`
  812. Returns ``true`` if the image is compressed.
  813. .. rst-class:: classref-item-separator
  814. ----
  815. .. _class_Image_method_is_empty:
  816. .. rst-class:: classref-method
  817. :ref:`bool<class_bool>` **is_empty**\ (\ ) |const| :ref:`🔗<class_Image_method_is_empty>`
  818. Returns ``true`` if the image has no data.
  819. .. rst-class:: classref-item-separator
  820. ----
  821. .. _class_Image_method_is_invisible:
  822. .. rst-class:: classref-method
  823. :ref:`bool<class_bool>` **is_invisible**\ (\ ) |const| :ref:`🔗<class_Image_method_is_invisible>`
  824. 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.
  825. .. rst-class:: classref-item-separator
  826. ----
  827. .. _class_Image_method_linear_to_srgb:
  828. .. rst-class:: classref-method
  829. |void| **linear_to_srgb**\ (\ ) :ref:`🔗<class_Image_method_linear_to_srgb>`
  830. Converts the entire image from linear encoding to nonlinear sRGB encoding by using a lookup table. Only works on images with :ref:`FORMAT_RGB8<class_Image_constant_FORMAT_RGB8>` or :ref:`FORMAT_RGBA8<class_Image_constant_FORMAT_RGBA8>` formats.
  831. .. rst-class:: classref-item-separator
  832. ----
  833. .. _class_Image_method_load:
  834. .. rst-class:: classref-method
  835. :ref:`Error<enum_@GlobalScope_Error>` **load**\ (\ path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_Image_method_load>`
  836. 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.
  837. \ **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.
  838. See also :ref:`ImageTexture<class_ImageTexture>` description for usage examples.
  839. .. rst-class:: classref-item-separator
  840. ----
  841. .. _class_Image_method_load_bmp_from_buffer:
  842. .. rst-class:: classref-method
  843. :ref:`Error<enum_@GlobalScope_Error>` **load_bmp_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_Image_method_load_bmp_from_buffer>`
  844. Loads an image from the binary contents of a BMP file.
  845. \ **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.
  846. \ **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.
  847. .. rst-class:: classref-item-separator
  848. ----
  849. .. _class_Image_method_load_dds_from_buffer:
  850. .. rst-class:: classref-method
  851. :ref:`Error<enum_@GlobalScope_Error>` **load_dds_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_Image_method_load_dds_from_buffer>`
  852. Loads an image from the binary contents of a DDS file.
  853. \ **Note:** This method is only available in engine builds with the DDS module enabled. By default, the DDS module is enabled, but it can be disabled at build-time using the ``module_dds_enabled=no`` SCons option.
  854. .. rst-class:: classref-item-separator
  855. ----
  856. .. _class_Image_method_load_from_file:
  857. .. rst-class:: classref-method
  858. :ref:`Image<class_Image>` **load_from_file**\ (\ path\: :ref:`String<class_String>`\ ) |static| :ref:`🔗<class_Image_method_load_from_file>`
  859. Creates a new **Image** and loads data from the specified file.
  860. .. rst-class:: classref-item-separator
  861. ----
  862. .. _class_Image_method_load_jpg_from_buffer:
  863. .. rst-class:: classref-method
  864. :ref:`Error<enum_@GlobalScope_Error>` **load_jpg_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_Image_method_load_jpg_from_buffer>`
  865. Loads an image from the binary contents of a JPEG file.
  866. .. rst-class:: classref-item-separator
  867. ----
  868. .. _class_Image_method_load_ktx_from_buffer:
  869. .. rst-class:: classref-method
  870. :ref:`Error<enum_@GlobalScope_Error>` **load_ktx_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_Image_method_load_ktx_from_buffer>`
  871. 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.
  872. \ **Note:** Godot's libktx implementation only supports 2D images. Cubemaps, texture arrays, and de-padding are not supported.
  873. \ **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.
  874. .. rst-class:: classref-item-separator
  875. ----
  876. .. _class_Image_method_load_png_from_buffer:
  877. .. rst-class:: classref-method
  878. :ref:`Error<enum_@GlobalScope_Error>` **load_png_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_Image_method_load_png_from_buffer>`
  879. Loads an image from the binary contents of a PNG file.
  880. .. rst-class:: classref-item-separator
  881. ----
  882. .. _class_Image_method_load_svg_from_buffer:
  883. .. rst-class:: classref-method
  884. :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>`
  885. Loads an image from the UTF-8 binary contents of an **uncompressed** SVG file (**.svg**).
  886. \ **Note:** Beware when using compressed SVG files (like **.svgz**), they need to be ``decompressed`` before loading.
  887. \ **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.
  888. .. rst-class:: classref-item-separator
  889. ----
  890. .. _class_Image_method_load_svg_from_string:
  891. .. rst-class:: classref-method
  892. :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>`
  893. Loads an image from the string contents of an SVG file (**.svg**).
  894. \ **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.
  895. .. rst-class:: classref-item-separator
  896. ----
  897. .. _class_Image_method_load_tga_from_buffer:
  898. .. rst-class:: classref-method
  899. :ref:`Error<enum_@GlobalScope_Error>` **load_tga_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_Image_method_load_tga_from_buffer>`
  900. Loads an image from the binary contents of a TGA file.
  901. \ **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.
  902. .. rst-class:: classref-item-separator
  903. ----
  904. .. _class_Image_method_load_webp_from_buffer:
  905. .. rst-class:: classref-method
  906. :ref:`Error<enum_@GlobalScope_Error>` **load_webp_from_buffer**\ (\ buffer\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_Image_method_load_webp_from_buffer>`
  907. Loads an image from the binary contents of a WebP file.
  908. .. rst-class:: classref-item-separator
  909. ----
  910. .. _class_Image_method_normal_map_to_xy:
  911. .. rst-class:: classref-method
  912. |void| **normal_map_to_xy**\ (\ ) :ref:`🔗<class_Image_method_normal_map_to_xy>`
  913. 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.
  914. .. rst-class:: classref-item-separator
  915. ----
  916. .. _class_Image_method_premultiply_alpha:
  917. .. rst-class:: classref-method
  918. |void| **premultiply_alpha**\ (\ ) :ref:`🔗<class_Image_method_premultiply_alpha>`
  919. 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>`.
  920. .. rst-class:: classref-item-separator
  921. ----
  922. .. _class_Image_method_resize:
  923. .. rst-class:: classref-method
  924. |void| **resize**\ (\ width\: :ref:`int<class_int>`, height\: :ref:`int<class_int>`, interpolation\: :ref:`Interpolation<enum_Image_Interpolation>` = 1\ ) :ref:`🔗<class_Image_method_resize>`
  925. 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.
  926. .. rst-class:: classref-item-separator
  927. ----
  928. .. _class_Image_method_resize_to_po2:
  929. .. rst-class:: classref-method
  930. |void| **resize_to_po2**\ (\ square\: :ref:`bool<class_bool>` = false, interpolation\: :ref:`Interpolation<enum_Image_Interpolation>` = 1\ ) :ref:`🔗<class_Image_method_resize_to_po2>`
  931. Resizes the image to the nearest power of 2 for the width and height. If ``square`` is ``true``, sets width and height to be the same. New pixels are calculated using the ``interpolation`` mode defined via :ref:`Interpolation<enum_Image_Interpolation>` constants.
  932. .. rst-class:: classref-item-separator
  933. ----
  934. .. _class_Image_method_rgbe_to_srgb:
  935. .. rst-class:: classref-method
  936. :ref:`Image<class_Image>` **rgbe_to_srgb**\ (\ ) :ref:`🔗<class_Image_method_rgbe_to_srgb>`
  937. Converts a standard linear RGBE (Red Green Blue Exponent) image to an image that uses nonlinear sRGB encoding.
  938. .. rst-class:: classref-item-separator
  939. ----
  940. .. _class_Image_method_rotate_90:
  941. .. rst-class:: classref-method
  942. |void| **rotate_90**\ (\ direction\: :ref:`ClockDirection<enum_@GlobalScope_ClockDirection>`\ ) :ref:`🔗<class_Image_method_rotate_90>`
  943. 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.
  944. .. rst-class:: classref-item-separator
  945. ----
  946. .. _class_Image_method_rotate_180:
  947. .. rst-class:: classref-method
  948. |void| **rotate_180**\ (\ ) :ref:`🔗<class_Image_method_rotate_180>`
  949. Rotates the image by ``180`` degrees. The width and height of the image must be greater than ``1``.
  950. .. rst-class:: classref-item-separator
  951. ----
  952. .. _class_Image_method_save_dds:
  953. .. rst-class:: classref-method
  954. :ref:`Error<enum_@GlobalScope_Error>` **save_dds**\ (\ path\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_Image_method_save_dds>`
  955. Saves the image as a DDS (DirectDraw Surface) file to ``path``. DDS is a container format that can store textures in various compression formats, such as DXT1, DXT5, or BC7. This function will return :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>` if Godot was compiled without the DDS module.
  956. \ **Note:** The DDS module may be disabled in certain builds, which means :ref:`save_dds()<class_Image_method_save_dds>` will return :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>` when it is called from an exported project.
  957. .. rst-class:: classref-item-separator
  958. ----
  959. .. _class_Image_method_save_dds_to_buffer:
  960. .. rst-class:: classref-method
  961. :ref:`PackedByteArray<class_PackedByteArray>` **save_dds_to_buffer**\ (\ ) |const| :ref:`🔗<class_Image_method_save_dds_to_buffer>`
  962. Saves the image as a DDS (DirectDraw Surface) file to a byte array. DDS is a container format that can store textures in various compression formats, such as DXT1, DXT5, or BC7. This function will return an empty byte array if Godot was compiled without the DDS module.
  963. \ **Note:** The DDS module may be disabled in certain builds, which means :ref:`save_dds_to_buffer()<class_Image_method_save_dds_to_buffer>` will return an empty byte array when it is called from an exported project.
  964. .. rst-class:: classref-item-separator
  965. ----
  966. .. _class_Image_method_save_exr:
  967. .. rst-class:: classref-method
  968. :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>`
  969. 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.
  970. \ **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.
  971. .. rst-class:: classref-item-separator
  972. ----
  973. .. _class_Image_method_save_exr_to_buffer:
  974. .. rst-class:: classref-method
  975. :ref:`PackedByteArray<class_PackedByteArray>` **save_exr_to_buffer**\ (\ grayscale\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_Image_method_save_exr_to_buffer>`
  976. 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.
  977. \ **Note:** The TinyEXR module is disabled in non-editor builds, which means :ref:`save_exr_to_buffer()<class_Image_method_save_exr_to_buffer>` will return an empty byte array when it is called from an exported project.
  978. .. rst-class:: classref-item-separator
  979. ----
  980. .. _class_Image_method_save_jpg:
  981. .. rst-class:: classref-method
  982. :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>`
  983. 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.
  984. \ **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.
  985. .. rst-class:: classref-item-separator
  986. ----
  987. .. _class_Image_method_save_jpg_to_buffer:
  988. .. rst-class:: classref-method
  989. :ref:`PackedByteArray<class_PackedByteArray>` **save_jpg_to_buffer**\ (\ quality\: :ref:`float<class_float>` = 0.75\ ) |const| :ref:`🔗<class_Image_method_save_jpg_to_buffer>`
  990. 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.
  991. \ **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.
  992. .. rst-class:: classref-item-separator
  993. ----
  994. .. _class_Image_method_save_png:
  995. .. rst-class:: classref-method
  996. :ref:`Error<enum_@GlobalScope_Error>` **save_png**\ (\ path\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_Image_method_save_png>`
  997. Saves the image as a PNG file to the file at ``path``.
  998. .. rst-class:: classref-item-separator
  999. ----
  1000. .. _class_Image_method_save_png_to_buffer:
  1001. .. rst-class:: classref-method
  1002. :ref:`PackedByteArray<class_PackedByteArray>` **save_png_to_buffer**\ (\ ) |const| :ref:`🔗<class_Image_method_save_png_to_buffer>`
  1003. Saves the image as a PNG file to a byte array.
  1004. .. rst-class:: classref-item-separator
  1005. ----
  1006. .. _class_Image_method_save_webp:
  1007. .. rst-class:: classref-method
  1008. :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>`
  1009. 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.
  1010. \ **Note:** The WebP format is limited to a size of 16383×16383 pixels, while PNG can save larger images.
  1011. .. rst-class:: classref-item-separator
  1012. ----
  1013. .. _class_Image_method_save_webp_to_buffer:
  1014. .. rst-class:: classref-method
  1015. :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>`
  1016. 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.
  1017. \ **Note:** The WebP format is limited to a size of 16383×16383 pixels, while PNG can save larger images.
  1018. .. rst-class:: classref-item-separator
  1019. ----
  1020. .. _class_Image_method_set_data:
  1021. .. rst-class:: classref-method
  1022. |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>`
  1023. Overwrites data of an existing **Image**. Non-static equivalent of :ref:`create_from_data()<class_Image_method_create_from_data>`.
  1024. .. rst-class:: classref-item-separator
  1025. ----
  1026. .. _class_Image_method_set_pixel:
  1027. .. rst-class:: classref-method
  1028. |void| **set_pixel**\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`, color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_Image_method_set_pixel>`
  1029. Sets the :ref:`Color<class_Color>` of the pixel at ``(x, y)`` to ``color``.
  1030. .. tabs::
  1031. .. code-tab:: gdscript
  1032. var img_width = 10
  1033. var img_height = 5
  1034. var img = Image.create(img_width, img_height, false, Image.FORMAT_RGBA8)
  1035. img.set_pixel(1, 2, Color.RED) # Sets the color at (1, 2) to red.
  1036. .. code-tab:: csharp
  1037. int imgWidth = 10;
  1038. int imgHeight = 5;
  1039. var img = Image.Create(imgWidth, imgHeight, false, Image.Format.Rgba8);
  1040. img.SetPixel(1, 2, Colors.Red); // Sets the color at (1, 2) to red.
  1041. 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.
  1042. .. rst-class:: classref-item-separator
  1043. ----
  1044. .. _class_Image_method_set_pixelv:
  1045. .. rst-class:: classref-method
  1046. |void| **set_pixelv**\ (\ point\: :ref:`Vector2i<class_Vector2i>`, color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_Image_method_set_pixelv>`
  1047. Sets the :ref:`Color<class_Color>` of the pixel at ``point`` to ``color``.
  1048. .. tabs::
  1049. .. code-tab:: gdscript
  1050. var img_width = 10
  1051. var img_height = 5
  1052. var img = Image.create(img_width, img_height, false, Image.FORMAT_RGBA8)
  1053. img.set_pixelv(Vector2i(1, 2), Color.RED) # Sets the color at (1, 2) to red.
  1054. .. code-tab:: csharp
  1055. int imgWidth = 10;
  1056. int imgHeight = 5;
  1057. var img = Image.Create(imgWidth, imgHeight, false, Image.Format.Rgba8);
  1058. img.SetPixelv(new Vector2I(1, 2), Colors.Red); // Sets the color at (1, 2) to red.
  1059. 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.
  1060. .. rst-class:: classref-item-separator
  1061. ----
  1062. .. _class_Image_method_shrink_x2:
  1063. .. rst-class:: classref-method
  1064. |void| **shrink_x2**\ (\ ) :ref:`🔗<class_Image_method_shrink_x2>`
  1065. Shrinks the image by a factor of 2 on each axis (this divides the pixel count by 4).
  1066. .. rst-class:: classref-item-separator
  1067. ----
  1068. .. _class_Image_method_srgb_to_linear:
  1069. .. rst-class:: classref-method
  1070. |void| **srgb_to_linear**\ (\ ) :ref:`🔗<class_Image_method_srgb_to_linear>`
  1071. Converts the raw data from nonlinear sRGB encoding to linear encoding using a lookup table. Only works on images with :ref:`FORMAT_RGB8<class_Image_constant_FORMAT_RGB8>` or :ref:`FORMAT_RGBA8<class_Image_constant_FORMAT_RGBA8>` formats.
  1072. \ **Note:** The 8-bit formats required by this method are not suitable for storing linearly encoded values; a significant amount of color information will be lost in darker values. To maintain image quality, this method should not be used.
  1073. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  1074. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  1075. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  1076. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  1077. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  1078. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  1079. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  1080. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  1081. .. |void| replace:: :abbr:`void (No return value.)`