Package icyllis.arc3d.core

# Class ColorInfo

java.lang.Object
icyllis.arc3d.core.ColorInfo

public final class ColorInfo extends Object
Describes pixel dimensions and encoding.

ColorInfo is used to interpret a color: color type + alpha type + color space.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static @interface`
  `ColorInfo.AlphaType`
  Describes how to interpret the alpha component of a pixel.
  `static @interface`
  `ColorInfo.ColorType`
  Describes how pixel bits encode color.
  `static @interface`
  `ColorInfo.CompressionType`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `AT_OPAQUE`
  Alpha types.
  `static final int`
  `AT_PREMUL`
  Alpha types.
  `static final int`
  `AT_UNKNOWN`
  Alpha types.
  `static final int`
  `AT_UNPREMUL`
  Alpha types.
  `static final int`
  `COMPRESSION_BC1_RGB8_UNORM`
  Compression types.
  `static final int`
  `COMPRESSION_BC1_RGBA8_UNORM`
  Compression types.
  `static final int`
  `COMPRESSION_COUNT`
  Compression types.
  `static final int`
  `COMPRESSION_ETC2_RGB8_UNORM`
  Compression types.
  `static final int`
  `COMPRESSION_NONE`
  Compression types.
  `static final int`
  `CT_A16_FLOAT`
  Aliases.
  `static final int`
  `CT_A16_UNORM`
  Aliases.
  `static final int`
  `CT_A16G16_UNORM`
  Aliases.
  `static final int`
  `CT_ABGR_8888`
  Special format for big-endian CPU; GPU does not support this.
  `static final int`
  `CT_ALPHA_16`
  `static final int`
  `CT_ALPHA_8`
  `static final int`
  `CT_ALPHA_F16`
  `static final int`
  `CT_ARGB_8888`
  Special format for big-endian CPU; GPU does not support this.
  `static final int`
  `CT_BGR_565`
  Color types.
  `static final int`
  `CT_BGRA_1010102`
  `static final int`
  `CT_BGRA_8888`
  `static final int`
  `CT_BGRA_8888_NATIVE`
  A runtime alias based on host endianness, packed as `(b << 0) | (g << 8) | (r << 16) | (a << 24)` an uint32 value.
  `static final int`
  `CT_COUNT`
  `static final int`
  `CT_GRAY_8`
  `static final int`
  `CT_GRAY_ALPHA_88`
  `static final int`
  `CT_R_16`
  `static final int`
  `CT_R_8`
  Color types.
  `static final int`
  `CT_R_F16`
  `static final int`
  `CT_R16G16_FLOAT`
  Aliases.
  `static final int`
  `CT_R16G16B16A16_UNORM`
  Aliases.
  `static final int`
  `CT_R5G6B5_UNORM`
  Aliases.
  `static final int`
  `CT_R8G8_UNORM`
  Aliases.
  `static final int`
  `CT_RG_1616`
  `static final int`
  `CT_RG_88`
  Color types.
  `static final int`
  `CT_RG_F16`
  `static final int`
  `CT_RGB_888`
  `static final int`
  `CT_RGBA_1010102`
  `static final int`
  `CT_RGBA_16161616`
  `static final int`
  `CT_RGBA_8888`
  `static final int`
  `CT_RGBA_8888_NATIVE`
  A runtime alias based on host endianness, packed as `(r << 0) | (g << 8) | (b << 16) | (a << 24)` an uint32 value.
  `static final int`
  `CT_RGBA_8888_SRGB`
  `static final int`
  `CT_RGBA_F16`
  `static final int`
  `CT_RGBA_F16_CLAMPED`
  `static final int`
  `CT_RGBA_F32`
  `static final int`
  `CT_RGBX_8888`
  `static final int`
  `CT_UNKNOWN`
  Color types.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static int`
  `bytesPerPixel(int ct)`
  Returns the number of bytes required to store a pixel.
  `static int`
  `colorTypeChannelFlags(int ct)`
  `static int`
  `colorTypeCount()`
  Returns the number of color types but avoids inlining at compile-time.
  `static boolean`
  `colorTypeIsAlphaOnly(int ct)`
  `static String`
  `colorTypeToString(int ct)`
  `static int`
  `maxBitsPerChannel(int ct)`
  `static int`
  `validateAlphaType(int ct, int at)`
  Returns a valid AlphaType for ct.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### COMPRESSION_NONE

    public static final int COMPRESSION_NONE
    Compression types.

    Core | GL_COMPRESSED_* | VK_FORMAT_*_BLOCK
    --- | --- | ---
    ETC2_RGB8_UNORM | RGB8_ETC2 | ETC2_R8G8B8_UNORM
    BC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | BC1_RGB_UNORM
    BC1_RGBA8_UNORM | RGBA_S3TC_DXT1_EXT | BC1_RGBA_UNORM

    See Also:
      - Constant Field Values

  - ### COMPRESSION_ETC2_RGB8_UNORM

    public static final int COMPRESSION_ETC2_RGB8_UNORM
    Compression types.

    Core | GL_COMPRESSED_* | VK_FORMAT_*_BLOCK
    --- | --- | ---
    ETC2_RGB8_UNORM | RGB8_ETC2 | ETC2_R8G8B8_UNORM
    BC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | BC1_RGB_UNORM
    BC1_RGBA8_UNORM | RGBA_S3TC_DXT1_EXT | BC1_RGBA_UNORM

    See Also:
      - Constant Field Values

  - ### COMPRESSION_BC1_RGB8_UNORM

    public static final int COMPRESSION_BC1_RGB8_UNORM
    Compression types.

    Core | GL_COMPRESSED_* | VK_FORMAT_*_BLOCK
    --- | --- | ---
    ETC2_RGB8_UNORM | RGB8_ETC2 | ETC2_R8G8B8_UNORM
    BC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | BC1_RGB_UNORM
    BC1_RGBA8_UNORM | RGBA_S3TC_DXT1_EXT | BC1_RGBA_UNORM

    See Also:
      - Constant Field Values

  - ### COMPRESSION_BC1_RGBA8_UNORM

    public static final int COMPRESSION_BC1_RGBA8_UNORM
    Compression types.

    Core | GL_COMPRESSED_* | VK_FORMAT_*_BLOCK
    --- | --- | ---
    ETC2_RGB8_UNORM | RGB8_ETC2 | ETC2_R8G8B8_UNORM
    BC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | BC1_RGB_UNORM
    BC1_RGBA8_UNORM | RGBA_S3TC_DXT1_EXT | BC1_RGBA_UNORM

    See Also:
      - Constant Field Values

  - ### COMPRESSION_COUNT

    public static final int COMPRESSION_COUNT
    Compression types.

    Core | GL_COMPRESSED_* | VK_FORMAT_*_BLOCK
    --- | --- | ---
    ETC2_RGB8_UNORM | RGB8_ETC2 | ETC2_R8G8B8_UNORM
    BC1_RGB8_UNORM | RGB_S3TC_DXT1_EXT | BC1_RGB_UNORM
    BC1_RGBA8_UNORM | RGBA_S3TC_DXT1_EXT | BC1_RGBA_UNORM

    See Also:
      - Constant Field Values

  - ### AT_UNKNOWN

    public static final int AT_UNKNOWN
    Alpha types.

    Describes how to interpret the alpha component of a pixel. A pixel may be opaque, or alpha, describing multiple levels of transparency.

    In simple blending, alpha weights the source color and the destination color to create a new color. If alpha describes a weight from zero to one:

    result color = source color * alpha + destination color * (1 - alpha)

    In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.

    RGB may have alpha included in each component value; the stored value is the original RGB multiplied by alpha. Premultiplied color components improve performance, but it will reduce the image quality. The usual practice is to premultiply alpha in the GPU, since they were converted into floating-point values.

    See Also:
      - Constant Field Values

  - ### AT_OPAQUE

    public static final int AT_OPAQUE
    Alpha types.

    Describes how to interpret the alpha component of a pixel. A pixel may be opaque, or alpha, describing multiple levels of transparency.

    In simple blending, alpha weights the source color and the destination color to create a new color. If alpha describes a weight from zero to one:

    result color = source color * alpha + destination color * (1 - alpha)

    In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.

    RGB may have alpha included in each component value; the stored value is the original RGB multiplied by alpha. Premultiplied color components improve performance, but it will reduce the image quality. The usual practice is to premultiply alpha in the GPU, since they were converted into floating-point values.

    See Also:
      - Constant Field Values

  - ### AT_PREMUL

    public static final int AT_PREMUL
    Alpha types.

    Describes how to interpret the alpha component of a pixel. A pixel may be opaque, or alpha, describing multiple levels of transparency.

    In simple blending, alpha weights the source color and the destination color to create a new color. If alpha describes a weight from zero to one:

    result color = source color * alpha + destination color * (1 - alpha)

    In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.

    RGB may have alpha included in each component value; the stored value is the original RGB multiplied by alpha. Premultiplied color components improve performance, but it will reduce the image quality. The usual practice is to premultiply alpha in the GPU, since they were converted into floating-point values.

    See Also:
      - Constant Field Values

  - ### AT_UNPREMUL

    public static final int AT_UNPREMUL
    Alpha types.

    Describes how to interpret the alpha component of a pixel. A pixel may be opaque, or alpha, describing multiple levels of transparency.

    In simple blending, alpha weights the source color and the destination color to create a new color. If alpha describes a weight from zero to one:

    result color = source color * alpha + destination color * (1 - alpha)

    In practice alpha is encoded in two or more bits, where 1.0 equals all bits set.

    RGB may have alpha included in each component value; the stored value is the original RGB multiplied by alpha. Premultiplied color components improve performance, but it will reduce the image quality. The usual practice is to premultiply alpha in the GPU, since they were converted into floating-point values.

    See Also:
      - Constant Field Values

  - ### CT_UNKNOWN

    public static final int CT_UNKNOWN
    Color types.

    Describes a layout of pixel data in CPU or GPU memory. A pixel may be an alpha mask, a grayscale, RGB, or RGBA. It specifies the channels, their type, and width. It does not refer to a texture format and the mapping to texture formats may be many-to-many. It does not specify the sRGB encoding of the stored values.

    Color types are divided into two classes: array and packed.
    For array types, the components are listed in order of where they appear in memory. For example, `CT_RGBA_8888` means that the pixel memory should be interpreted as an array of uint8 values, and the R channel appears at the first uint8 value. This is the same naming convention as Vulkan.
    For packed types, the first component appear in the least-significant bits. For example, `CT_BGR_565` means that each pixel is packed as `(b << 0) | (g << 5) | (r << 11)`, an uint16 value. This is in the reverse order of Vulkan's naming convention.

    Note that if bytes-per-pixel of a color type is 1, 2, 4, or 8, then Arc3D requires pixel memory to be aligned to bytes-per-pixel, otherwise it should be aligned to the size of data type as normal.

    See Also:
      - Constant Field Values

  - ### CT_BGR_565

    public static final int CT_BGR_565
    Color types.

    Describes a layout of pixel data in CPU or GPU memory. A pixel may be an alpha mask, a grayscale, RGB, or RGBA. It specifies the channels, their type, and width. It does not refer to a texture format and the mapping to texture formats may be many-to-many. It does not specify the sRGB encoding of the stored values.

    Color types are divided into two classes: array and packed.
    For array types, the components are listed in order of where they appear in memory. For example, `CT_RGBA_8888` means that the pixel memory should be interpreted as an array of uint8 values, and the R channel appears at the first uint8 value. This is the same naming convention as Vulkan.
    For packed types, the first component appear in the least-significant bits. For example, `CT_BGR_565` means that each pixel is packed as `(b << 0) | (g << 5) | (r << 11)`, an uint16 value. This is in the reverse order of Vulkan's naming convention.

    Note that if bytes-per-pixel of a color type is 1, 2, 4, or 8, then Arc3D requires pixel memory to be aligned to bytes-per-pixel, otherwise it should be aligned to the size of data type as normal.

    See Also:
      - Constant Field Values

  - ### CT_R_8

    public static final int CT_R_8
    Color types.

    Describes a layout of pixel data in CPU or GPU memory. A pixel may be an alpha mask, a grayscale, RGB, or RGBA. It specifies the channels, their type, and width. It does not refer to a texture format and the mapping to texture formats may be many-to-many. It does not specify the sRGB encoding of the stored values.

    Color types are divided into two classes: array and packed.
    For array types, the components are listed in order of where they appear in memory. For example, `CT_RGBA_8888` means that the pixel memory should be interpreted as an array of uint8 values, and the R channel appears at the first uint8 value. This is the same naming convention as Vulkan.
    For packed types, the first component appear in the least-significant bits. For example, `CT_BGR_565` means that each pixel is packed as `(b << 0) | (g << 5) | (r << 11)`, an uint16 value. This is in the reverse order of Vulkan's naming convention.

    Note that if bytes-per-pixel of a color type is 1, 2, 4, or 8, then Arc3D requires pixel memory to be aligned to bytes-per-pixel, otherwise it should be aligned to the size of data type as normal.

    See Also:
      - Constant Field Values

  - ### CT_RG_88

    public static final int CT_RG_88
    Color types.

    Describes a layout of pixel data in CPU or GPU memory. A pixel may be an alpha mask, a grayscale, RGB, or RGBA. It specifies the channels, their type, and width. It does not refer to a texture format and the mapping to texture formats may be many-to-many. It does not specify the sRGB encoding of the stored values.

    Color types are divided into two classes: array and packed.
    For array types, the components are listed in order of where they appear in memory. For example, `CT_RGBA_8888` means that the pixel memory should be interpreted as an array of uint8 values, and the R channel appears at the first uint8 value. This is the same naming convention as Vulkan.
    For packed types, the first component appear in the least-significant bits. For example, `CT_BGR_565` means that each pixel is packed as `(b << 0) | (g << 5) | (r << 11)`, an uint16 value. This is in the reverse order of Vulkan's naming convention.

    Note that if bytes-per-pixel of a color type is 1, 2, 4, or 8, then Arc3D requires pixel memory to be aligned to bytes-per-pixel, otherwise it should be aligned to the size of data type as normal.

    See Also:
      - Constant Field Values

  - ### CT_RGB_888

    @Internal public static final int CT_RGB_888
    See Also:
      - Constant Field Values

  - ### CT_RGBX_8888

    public static final int CT_RGBX_8888
    See Also:
      - Constant Field Values

  - ### CT_RGBA_8888

    public static final int CT_RGBA_8888
    See Also:
      - Constant Field Values

  - ### CT_BGRA_8888

    public static final int CT_BGRA_8888
    See Also:
      - Constant Field Values

  - ### CT_RGBA_8888_SRGB

    @Internal public static final int CT_RGBA_8888_SRGB
    See Also:
      - Constant Field Values

  - ### CT_RGBA_1010102

    public static final int CT_RGBA_1010102
    See Also:
      - Constant Field Values

  - ### CT_BGRA_1010102

    public static final int CT_BGRA_1010102
    See Also:
      - Constant Field Values

  - ### CT_R_16

    @Internal public static final int CT_R_16
    See Also:
      - Constant Field Values

  - ### CT_R_F16

    @Internal public static final int CT_R_F16
    See Also:
      - Constant Field Values

  - ### CT_RG_1616

    @Internal public static final int CT_RG_1616
    See Also:
      - Constant Field Values

  - ### CT_RG_F16

    @Internal public static final int CT_RG_F16
    See Also:
      - Constant Field Values

  - ### CT_RGBA_16161616

    public static final int CT_RGBA_16161616
    See Also:
      - Constant Field Values

  - ### CT_RGBA_F16

    public static final int CT_RGBA_F16
    See Also:
      - Constant Field Values

  - ### CT_RGBA_F16_CLAMPED

    public static final int CT_RGBA_F16_CLAMPED
    See Also:
      - Constant Field Values

  - ### CT_RGBA_F32

    public static final int CT_RGBA_F32
    See Also:
      - Constant Field Values

  - ### CT_ALPHA_8

    public static final int CT_ALPHA_8
    See Also:
      - Constant Field Values

  - ### CT_ALPHA_16

    public static final int CT_ALPHA_16
    See Also:
      - Constant Field Values

  - ### CT_ALPHA_F16

    public static final int CT_ALPHA_F16
    See Also:
      - Constant Field Values

  - ### CT_GRAY_8

    public static final int CT_GRAY_8
    See Also:
      - Constant Field Values

  - ### CT_GRAY_ALPHA_88

    @Internal public static final int CT_GRAY_ALPHA_88
    See Also:
      - Constant Field Values

  - ### CT_ABGR_8888

    @Internal public static final int CT_ABGR_8888
    Special format for big-endian CPU; GPU does not support this.
    See Also:
      - Constant Field Values

  - ### CT_ARGB_8888

    @Internal public static final int CT_ARGB_8888
    Special format for big-endian CPU; GPU does not support this.
    See Also:
      - Constant Field Values

  - ### CT_RGBA_8888_NATIVE

    public static final int CT_RGBA_8888_NATIVE
    A runtime alias based on host endianness, packed as `(r << 0) | (g << 8) | (b << 16) | (a << 24)` an uint32 value.

    This is not a standalone packed format, it just depends on CPU: on big-endian machine this is `CT_ABGR_8888`; on little-endian machine this is `CT_RGBA_8888`.

  - ### CT_BGRA_8888_NATIVE

    public static final int CT_BGRA_8888_NATIVE
    A runtime alias based on host endianness, packed as `(b << 0) | (g << 8) | (r << 16) | (a << 24)` an uint32 value.

    This is not a standalone packed format, it just depends on CPU: on big-endian machine this is `CT_ARGB_8888`; on little-endian machine this is `CT_BGRA_8888`.

  - ### CT_R5G6B5_UNORM

    public static final int CT_R5G6B5_UNORM
    Aliases.
    See Also:
      - Constant Field Values

  - ### CT_R8G8_UNORM

    public static final int CT_R8G8_UNORM
    Aliases.
    See Also:
      - Constant Field Values

  - ### CT_A16_UNORM

    public static final int CT_A16_UNORM
    Aliases.
    See Also:
      - Constant Field Values

  - ### CT_A16_FLOAT

    public static final int CT_A16_FLOAT
    Aliases.
    See Also:
      - Constant Field Values

  - ### CT_A16G16_UNORM

    public static final int CT_A16G16_UNORM
    Aliases.
    See Also:
      - Constant Field Values

  - ### CT_R16G16_FLOAT

    public static final int CT_R16G16_FLOAT
    Aliases.
    See Also:
      - Constant Field Values

  - ### CT_R16G16B16A16_UNORM

    public static final int CT_R16G16B16A16_UNORM
    Aliases.
    See Also:
      - Constant Field Values

  - ### CT_COUNT

    @Internal public static final int CT_COUNT
    See Also:
      - Constant Field Values

- ## Method Details

  - ### colorTypeCount

    public static int colorTypeCount()
    Returns the number of color types but avoids inlining at compile-time.

  - ### bytesPerPixel

    public static int bytesPerPixel(int ct)
    Returns the number of bytes required to store a pixel.
    Returns:
      bytes per pixel

  - ### maxBitsPerChannel

    public static int maxBitsPerChannel(int ct)

  - ### validateAlphaType

    public static int validateAlphaType(int ct, int at)
    Returns a valid AlphaType for ct. If there is more than one valid AlphaType, returns at, if valid.
    Returns:
      a valid AlphaType
    Throws:
      `IllegalArgumentException` - at is unknown, ct is not unknown, and ct has alpha channel.

  - ### colorTypeChannelFlags

    @Internal public static int colorTypeChannelFlags(int ct)

  - ### colorTypeIsAlphaOnly

    public static boolean colorTypeIsAlphaOnly(int ct)

  - ### colorTypeToString

    public static String colorTypeToString(int ct)