class_imagetexture.rst 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the ImageTexture.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_ImageTexture:
  6. ImageTexture
  7. ============
  8. **Inherits:** :ref:`Texture<class_Texture>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. A :ref:`Texture<class_Texture>` based on an :ref:`Image<class_Image>`.
  10. Description
  11. -----------
  12. A :ref:`Texture<class_Texture>` based on an :ref:`Image<class_Image>`. Can be created from an :ref:`Image<class_Image>` with :ref:`create_from_image<class_ImageTexture_method_create_from_image>`.
  13. **Note:** The maximum image size is 16384×16384 pixels due to graphics hardware limitations. Larger images will fail to import.
  14. Properties
  15. ----------
  16. +-------------------------------------------+-----------------------------------------------------------------+---------------------------+
  17. | :ref:`int<class_int>` | flags | ``7`` *(parent override)* |
  18. +-------------------------------------------+-----------------------------------------------------------------+---------------------------+
  19. | :ref:`float<class_float>` | :ref:`lossy_quality<class_ImageTexture_property_lossy_quality>` | ``0.7`` |
  20. +-------------------------------------------+-----------------------------------------------------------------+---------------------------+
  21. | :ref:`Storage<enum_ImageTexture_Storage>` | :ref:`storage<class_ImageTexture_property_storage>` | ``0`` |
  22. +-------------------------------------------+-----------------------------------------------------------------+---------------------------+
  23. Methods
  24. -------
  25. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`create<class_ImageTexture_method_create>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`Format<enum_Image_Format>` format, :ref:`int<class_int>` flags=7 **)** |
  27. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`create_from_image<class_ImageTexture_method_create_from_image>` **(** :ref:`Image<class_Image>` image, :ref:`int<class_int>` flags=7 **)** |
  29. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Format<enum_Image_Format>` | :ref:`get_format<class_ImageTexture_method_get_format>` **(** **)** |const| |
  31. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load<class_ImageTexture_method_load>` **(** :ref:`String<class_String>` path **)** |
  33. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_data<class_ImageTexture_method_set_data>` **(** :ref:`Image<class_Image>` image **)** |
  35. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_size_override<class_ImageTexture_method_set_size_override>` **(** :ref:`Vector2<class_Vector2>` size **)** |
  37. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. Enumerations
  39. ------------
  40. .. _enum_ImageTexture_Storage:
  41. .. _class_ImageTexture_constant_STORAGE_RAW:
  42. .. _class_ImageTexture_constant_STORAGE_COMPRESS_LOSSY:
  43. .. _class_ImageTexture_constant_STORAGE_COMPRESS_LOSSLESS:
  44. enum **Storage**:
  45. - **STORAGE_RAW** = **0** --- :ref:`Image<class_Image>` data is stored raw and unaltered.
  46. - **STORAGE_COMPRESS_LOSSY** = **1** --- :ref:`Image<class_Image>` data is compressed with a lossy algorithm. You can set the storage quality with :ref:`lossy_quality<class_ImageTexture_property_lossy_quality>`.
  47. - **STORAGE_COMPRESS_LOSSLESS** = **2** --- :ref:`Image<class_Image>` data is compressed with a lossless algorithm.
  48. Property Descriptions
  49. ---------------------
  50. .. _class_ImageTexture_property_lossy_quality:
  51. - :ref:`float<class_float>` **lossy_quality**
  52. +-----------+----------------------------------+
  53. | *Default* | ``0.7`` |
  54. +-----------+----------------------------------+
  55. | *Setter* | set_lossy_storage_quality(value) |
  56. +-----------+----------------------------------+
  57. | *Getter* | get_lossy_storage_quality() |
  58. +-----------+----------------------------------+
  59. The storage quality for :ref:`STORAGE_COMPRESS_LOSSY<class_ImageTexture_constant_STORAGE_COMPRESS_LOSSY>`.
  60. ----
  61. .. _class_ImageTexture_property_storage:
  62. - :ref:`Storage<enum_ImageTexture_Storage>` **storage**
  63. +-----------+--------------------+
  64. | *Default* | ``0`` |
  65. +-----------+--------------------+
  66. | *Setter* | set_storage(value) |
  67. +-----------+--------------------+
  68. | *Getter* | get_storage() |
  69. +-----------+--------------------+
  70. The storage type (raw, lossy, or compressed).
  71. Method Descriptions
  72. -------------------
  73. .. _class_ImageTexture_method_create:
  74. - void **create** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`Format<enum_Image_Format>` format, :ref:`int<class_int>` flags=7 **)**
  75. Create a new ``ImageTexture`` with ``width`` and ``height``.
  76. ``format`` is a value from :ref:`Format<enum_Image_Format>`, ``flags`` is any combination of :ref:`Flags<enum_Texture_Flags>`.
  77. ----
  78. .. _class_ImageTexture_method_create_from_image:
  79. - void **create_from_image** **(** :ref:`Image<class_Image>` image, :ref:`int<class_int>` flags=7 **)**
  80. Create a new ``ImageTexture`` from an :ref:`Image<class_Image>` with ``flags`` from :ref:`Flags<enum_Texture_Flags>`. An sRGB to linear color space conversion can take place, according to :ref:`Format<enum_Image_Format>`.
  81. ----
  82. .. _class_ImageTexture_method_get_format:
  83. - :ref:`Format<enum_Image_Format>` **get_format** **(** **)** |const|
  84. Returns the format of the ``ImageTexture``, one of :ref:`Format<enum_Image_Format>`.
  85. ----
  86. .. _class_ImageTexture_method_load:
  87. - :ref:`Error<enum_@GlobalScope_Error>` **load** **(** :ref:`String<class_String>` path **)**
  88. Load an ``ImageTexture`` from a file path.
  89. ----
  90. .. _class_ImageTexture_method_set_data:
  91. - void **set_data** **(** :ref:`Image<class_Image>` image **)**
  92. Sets the :ref:`Image<class_Image>` of this ``ImageTexture``.
  93. ----
  94. .. _class_ImageTexture_method_set_size_override:
  95. - void **set_size_override** **(** :ref:`Vector2<class_Vector2>` size **)**
  96. Resizes the ``ImageTexture`` to the specified dimensions.
  97. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  98. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  99. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`