class_image.rst 110 KB

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