Files
godot-docs/classes/class_imagetexture.rst
2021-03-16 12:29:34 +01:00

157 lines
8.3 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the ImageTexture.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_ImageTexture:
ImageTexture
============
**Inherits:** :ref:`Texture<class_Texture>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
A :ref:`Texture<class_Texture>` based on an :ref:`Image<class_Image>`.
Description
-----------
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>`.
**Note:** The maximum image size is 16384×16384 pixels due to graphics hardware limitations. Larger images will fail to import.
Properties
----------
+-------------------------------------------+-----------------------------------------------------------------+---------------------------+
| :ref:`int<class_int>` | flags | ``7`` *(parent override)* |
+-------------------------------------------+-----------------------------------------------------------------+---------------------------+
| :ref:`float<class_float>` | :ref:`lossy_quality<class_ImageTexture_property_lossy_quality>` | ``0.7`` |
+-------------------------------------------+-----------------------------------------------------------------+---------------------------+
| :ref:`Storage<enum_ImageTexture_Storage>` | :ref:`storage<class_ImageTexture_property_storage>` | ``0`` |
+-------------------------------------------+-----------------------------------------------------------------+---------------------------+
Methods
-------
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 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 **)** |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`create_from_image<class_ImageTexture_method_create_from_image>` **(** :ref:`Image<class_Image>` image, :ref:`int<class_int>` flags=7 **)** |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Format<enum_Image_Format>` | :ref:`get_format<class_ImageTexture_method_get_format>` **(** **)** |const| |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load<class_ImageTexture_method_load>` **(** :ref:`String<class_String>` path **)** |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_data<class_ImageTexture_method_set_data>` **(** :ref:`Image<class_Image>` image **)** |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_size_override<class_ImageTexture_method_set_size_override>` **(** :ref:`Vector2<class_Vector2>` size **)** |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Enumerations
------------
.. _enum_ImageTexture_Storage:
.. _class_ImageTexture_constant_STORAGE_RAW:
.. _class_ImageTexture_constant_STORAGE_COMPRESS_LOSSY:
.. _class_ImageTexture_constant_STORAGE_COMPRESS_LOSSLESS:
enum **Storage**:
- **STORAGE_RAW** = **0** --- :ref:`Image<class_Image>` data is stored raw and unaltered.
- **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>`.
- **STORAGE_COMPRESS_LOSSLESS** = **2** --- :ref:`Image<class_Image>` data is compressed with a lossless algorithm.
Property Descriptions
---------------------
.. _class_ImageTexture_property_lossy_quality:
- :ref:`float<class_float>` **lossy_quality**
+-----------+----------------------------------+
| *Default* | ``0.7`` |
+-----------+----------------------------------+
| *Setter* | set_lossy_storage_quality(value) |
+-----------+----------------------------------+
| *Getter* | get_lossy_storage_quality() |
+-----------+----------------------------------+
The storage quality for :ref:`STORAGE_COMPRESS_LOSSY<class_ImageTexture_constant_STORAGE_COMPRESS_LOSSY>`.
----
.. _class_ImageTexture_property_storage:
- :ref:`Storage<enum_ImageTexture_Storage>` **storage**
+-----------+--------------------+
| *Default* | ``0`` |
+-----------+--------------------+
| *Setter* | set_storage(value) |
+-----------+--------------------+
| *Getter* | get_storage() |
+-----------+--------------------+
The storage type (raw, lossy, or compressed).
Method Descriptions
-------------------
.. _class_ImageTexture_method_create:
- void **create** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`Format<enum_Image_Format>` format, :ref:`int<class_int>` flags=7 **)**
Create a new ``ImageTexture`` with ``width`` and ``height``.
``format`` is a value from :ref:`Format<enum_Image_Format>`, ``flags`` is any combination of :ref:`Flags<enum_Texture_Flags>`.
----
.. _class_ImageTexture_method_create_from_image:
- void **create_from_image** **(** :ref:`Image<class_Image>` image, :ref:`int<class_int>` flags=7 **)**
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>`.
----
.. _class_ImageTexture_method_get_format:
- :ref:`Format<enum_Image_Format>` **get_format** **(** **)** |const|
Returns the format of the ``ImageTexture``, one of :ref:`Format<enum_Image_Format>`.
----
.. _class_ImageTexture_method_load:
- :ref:`Error<enum_@GlobalScope_Error>` **load** **(** :ref:`String<class_String>` path **)**
Load an ``ImageTexture`` from a file path.
----
.. _class_ImageTexture_method_set_data:
- void **set_data** **(** :ref:`Image<class_Image>` image **)**
Sets the :ref:`Image<class_Image>` of this ``ImageTexture``.
----
.. _class_ImageTexture_method_set_size_override:
- void **set_size_override** **(** :ref:`Vector2<class_Vector2>` size **)**
Resizes the ``ImageTexture`` to the specified dimensions.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`