======= Texture ======= .. py:currentmodule:: p3dsdk .. py:class:: ImageDynamic .. py:attribute:: BYTE :annotation: = 1 Unsigned byte image, 8 bits/channel, :math:`[0, 255]` range. .. py:attribute:: SHORT :annotation: = 2 Unsigned short, 16 bits/channel, :math:`[0, 65535]` range. .. py:attribute:: FLOAT :annotation: = 4 Float, 32 bits/channel, :math:`[0.0, 1.0]` range. ImageFormat ----------- .. py:class:: ImageFormat .. py:attribute:: GREY :annotation: = 1 Greyscale image. .. py:attribute:: GREY_ALPHA :annotation: = 2 Greyscale image with alpha. .. py:attribute:: RGB :annotation: = 3 Color image. .. py:attribute:: RGBA :annotation: = 4 Color image with alpha. .. py:attribute:: BGR :annotation: = 5 Color image (red and blue channels swapped). .. py:attribute:: BGRA :annotation: = 6 Color image (red and blue channels swapped) with alpha. Texture ------- .. py:class:: Texture .. py:method:: id :property: The id of the texture. :type: str, read-only .. py:method:: name :property: The name of the texture. :type: str :raises ReadOnlyError: If :py:obj:`Database` is in read only mode. .. py:method:: group :property: The group of the texture. :type: TextureGroup :raises ReadOnlyError: If :py:obj:`Database` is in read only mode. .. py:method:: width :property: The texture width in pixels. :type: int, read-only .. py:method:: height :property: The texture height in pixels. :type: int, read-only .. py:method:: dpi_x :property: The texture DPI (dots/inch) in X direction. :type: float :raises ReadOnlyError: If :py:obj:`Database` is in read only mode. .. py:method:: dpi_y :property: The texture DPI (dots/inch) in Y direction. :type: float :raises ReadOnlyError: If :py:obj:`Database` is in read only mode. .. py:method:: format :property: The format of the image. :type: ImageFormat, read-only .. py:method:: dynamic :property: The pixel type of the image. :type: ImageDynamic, read-only .. py:method:: encoded_data(format, compression = -1) Get the encoded data of the texture. :param format: The file format to encode the image to (jpeg, png, tiff, exr, bmp, targa, webp, xpm, hdr). :type format: str :param compression: The compression value to use while encoding. The value to use depend on the format (e.g. 0 to 100 for JPEG, 0 to 9 for PNG). -1 means default compression value. :type compression: int :returns: The encoded data. :rtype: bytes .. py:method:: remove(force = False) Delete this texture .. note:: By default, only not used textures can be deleted (:py:obj:`InUseError` is raised otherwise), use ``force`` to force deletion of used textures. :param force: Force the deletion of the texture even if it is in use. :type force: bool :raises InUseError: If ``force`` is :py:obj:`False` and the texture is used. :raises ReadOnlyError: If :py:obj:`Database` is in read only mode.