2
0

class_image.rst 119 KB

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