Package icyllis.modernui.graphics

# Enum Class Bitmap.Format

java.lang.Object
java.lang.Enum<Bitmap.Format>
icyllis.modernui.graphics.Bitmap.Format

All Implemented Interfaces:
  `Serializable`, `Comparable<Bitmap.Format>`, `Constable`

Enclosing class:
  `Bitmap`

public static enum Bitmap.Format extends Enum<Bitmap.Format>
Describes a layout of pixel data in CPU memory. A pixel may be an alpha mask, a grayscale, RGB, or RGBA. It specifies the channels, their type, and width.

Bitmap formats 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, `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, `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 ModernUI requires pixel memory to be aligned to bytes-per-pixel, otherwise it should be aligned to the size of basic data type.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class java.lang.Enum

  `Enum.EnumDesc<E extends Enum<E>>`

- ## Enum Constant Summary

  Enum Constants
  Enum Constant
  Description
  `ABGR_8888`
  RGB, with alpha, four channels, 8-bit unsigned per channel.
  `ALPHA_16`
  Alpha mask, one channel, 16-bit unsigned per channel.
  `ALPHA_8`
  Alpha mask, one channel, 8-bit unsigned per channel.
  `ALPHA_F16`
  Alpha mask, one channel, 16-bit half float per channel.
  `ARGB_8888`
  RGB, with alpha, four channels, 8-bit unsigned per channel.
  `BGR_565`
  RGB, packed three channels, 16-bit unsigned per pixel.
  `BGRA_1010102`
  RGB, with alpha, packed four channels, 32-bit unsigned per pixel.
  `BGRA_8888`
  RGB, with alpha, four channels, 8-bit unsigned per channel.
  `BGRA_8888_PACK32`
  RGB, with alpha, packed four channels, 32-bit unsigned per pixel.
  `GRAY_16`
  Unsupported, DO NOT USE.
  `GRAY_8`
  Grayscale, one channel, 8-bit unsigned per channel.
  `GRAY_ALPHA_1616`
  Unsupported, DO NOT USE.
  `GRAY_ALPHA_88`
  Grayscale, with alpha, two channels, 8-bit unsigned per channel.
  `GRAY_ALPHA_F32`
  Unsupported, DO NOT USE.
  `GRAY_F32`
  Unsupported, DO NOT USE.
  `R_16`
  Red, one channel, 16-bit unsigned per channel.
  `R_8`
  Red, one channel, 8-bit unsigned per channel.
  `R_F16`
  Red, one channel, 16-bit half float per channel.
  `RG_1616`
  RG, two channels, 16-bit unsigned per channel.
  `RG_88`
  RG, two channels, 8-bit unsigned per channel.
  `RG_F16`
  RG, two channels, 16-bit half float per channel.
  `RGB_161616`
  Unsupported, DO NOT USE.
  `RGB_888`
  RGB, three channels, 8-bit unsigned per channel.
  `RGB_F32`
  Unsupported, DO NOT USE.
  `RGBA_1010102`
  RGB, with alpha, packed four channels, 32-bit unsigned per pixel.
  `RGBA_16161616`
  RGB, with alpha, four channels, 16-bit unsigned per channel.
  `RGBA_8888`
  RGB, with alpha, four channels, 8-bit unsigned per channel.
  `RGBA_8888_PACK32`
  RGB, with alpha, packed four channels, 32-bit unsigned per pixel.
  `RGBA_F16`
  RGB, with alpha, four channels, 32-bit half float per channel.
  `RGBA_F32`
  RGB, with alpha, four channels, 32-bit floating-point per channel.
  `RGBX_8888`
  RGB, four channels, 8-bit unsigned per channel.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getBytesPerPixel()`
  `int`
  `getChannels()`
  Returns the number of channels.
  `int`
  `getColorType()`
  The source (in CPU memory) color type of this format.
  `boolean`
  `hasAlpha()`
  Does this format have alpha channel?
  `boolean`
  `isChannelHDR()`
  Is this format 32-bit per channel and encoded as float?
  `boolean`
  `isChannelU16()`
  Is this format 16-bit per channel and encoded as unsigned short?
  `boolean`
  `isChannelU8()`
  Is this format 8-bit per channel and encoded as unsigned byte?
  `static Bitmap.Format`
  `valueOf(String name)`
  Returns the enum constant of this class with the specified name.
  `static Bitmap.Format[]`
  `values()`
  Returns an array containing the constants of this enum class, in the order they are declared.

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

  `clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

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

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### GRAY_8

    public static final Bitmap.Format GRAY_8
    Grayscale, one channel, 8-bit unsigned per channel. Basic data type: byte.

         0       1  byte
         | gray  |

  - ### GRAY_ALPHA_88

    public static final Bitmap.Format GRAY_ALPHA_88
    Grayscale, with alpha, two channels, 8-bit unsigned per channel. Basic data type: byte.

         0       1       2  byte
         | gray  | alpha |

  - ### RGB_888

    public static final Bitmap.Format RGB_888
    RGB, three channels, 8-bit unsigned per channel. Basic data type: byte.

         0       1       2       3  byte
         |   r   |   g   |   b   |

    Because the bpp of this format is not a power of 2, operations on this format will be slower.

  - ### RGBA_8888

    public static final Bitmap.Format RGBA_8888
    RGB, with alpha, four channels, 8-bit unsigned per channel. Basic data type: byte.

         0       1       2       3       4  byte
         |   r   |   g   |   b   |   a   |

  - ### GRAY_16

    @Internal public static final Bitmap.Format GRAY_16
    Unsupported, DO NOT USE.

         0       2  byte
         | gray  |

  - ### GRAY_ALPHA_1616

    @Internal public static final Bitmap.Format GRAY_ALPHA_1616
    Unsupported, DO NOT USE.

         0       2       4  byte
         | gray  | alpha |

  - ### RGB_161616

    @Internal public static final Bitmap.Format RGB_161616
    Unsupported, DO NOT USE.

         0       2       4       6  byte
         |   r   |   g   |   b   |

  - ### RGBA_16161616

    public static final Bitmap.Format RGBA_16161616
    RGB, with alpha, four channels, 16-bit unsigned per channel. Basic data type: short.

         0       2       4       6       8  byte
         |   r   |   g   |   b   |   a   |

  - ### GRAY_F32

    @Internal public static final Bitmap.Format GRAY_F32
    Unsupported, DO NOT USE.

  - ### GRAY_ALPHA_F32

    @Internal public static final Bitmap.Format GRAY_ALPHA_F32
    Unsupported, DO NOT USE.

  - ### RGB_F32

    @Internal public static final Bitmap.Format RGB_F32
    Unsupported, DO NOT USE.

  - ### RGBA_F32

    public static final Bitmap.Format RGBA_F32
    RGB, with alpha, four channels, 32-bit floating-point per channel. Basic data type: float.

         0       4       8      12      16  byte
         |   r   |   g   |   b   |   a   |

  - ### ALPHA_8

    public static final Bitmap.Format ALPHA_8
    Alpha mask, one channel, 8-bit unsigned per channel. Basic data type: byte.

         0       1  byte
         | alpha |

  - ### R_8

    public static final Bitmap.Format R_8
    Red, one channel, 8-bit unsigned per channel. Basic data type: byte.

         0       1  byte
         |   r   |

  - ### RG_88

    public static final Bitmap.Format RG_88
    RG, two channels, 8-bit unsigned per channel. Basic data type: byte.

         0       1       2  byte
         |   r   |   g   |

  - ### ALPHA_16

    public static final Bitmap.Format ALPHA_16
    Alpha mask, one channel, 16-bit unsigned per channel. Basic data type: short.

         0       2  byte
         | alpha |

  - ### R_16

    public static final Bitmap.Format R_16
    Red, one channel, 16-bit unsigned per channel. Basic data type: short.

         0       2  byte
         |   r   |

  - ### RG_1616

    public static final Bitmap.Format RG_1616
    RG, two channels, 16-bit unsigned per channel. Basic data type: short.

         0       2       4  byte
         |   r   |   g   |

  - ### ALPHA_F16

    public static final Bitmap.Format ALPHA_F16
    Alpha mask, one channel, 16-bit half float per channel. Basic data type: short.

         0       2  byte
         | alpha |

  - ### R_F16

    public static final Bitmap.Format R_F16
    Red, one channel, 16-bit half float per channel. Basic data type: short.

         0       2  byte
         |   r   |

  - ### RG_F16

    public static final Bitmap.Format RG_F16
    RG, two channels, 16-bit half float per channel. Basic data type: short.

         0       2       4  byte
         |   r   |   g   |

  - ### RGBA_F16

    public static final Bitmap.Format RGBA_F16
    RGB, with alpha, four channels, 32-bit half float per channel. Basic data type: short.

         0       2       4       6       8  byte
         |   r   |   g   |   b   |   a   |

  - ### BGR_565

    public static final Bitmap.Format BGR_565
    RGB, packed three channels, 16-bit unsigned per pixel. Basic data type: short.

         0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16  bit
         |      b       |        g        |      r       |

         short color = (B invalid input: '&' 0x1f) | (G invalid input: '&' 0x3f) invalid input: '<'invalid input: '<' 5 | (R invalid input: '&' 0x1f) invalid input: '<'invalid input: '<' 11;

  - ### RGBA_1010102

    public static final Bitmap.Format RGBA_1010102
    RGB, with alpha, packed four channels, 32-bit unsigned per pixel. Basic data type: int.

         0  2  4  6  8 10 12 14 16 18 20 22 24 26 28 30 32  bit
         |      r       |       g      |       b      | a|

         int color = (R invalid input: '&' 0x3ff) | (G invalid input: '&' 0x3ff) invalid input: '<'invalid input: '<' 10 | (B invalid input: '&' 0x3ff) invalid input: '<'invalid input: '<' 20 | (A invalid input: '&' 0x3) invalid input: '<'invalid input: '<' 30;

  - ### BGRA_1010102

    @Experimental public static final Bitmap.Format BGRA_1010102
    RGB, with alpha, packed four channels, 32-bit unsigned per pixel. Basic data type: int.

         0  2  4  6  8 10 12 14 16 18 20 22 24 26 28 30 32  bit
         |      b       |       g      |       r      | a|

         int color = (B invalid input: '&' 0x3ff) | (G invalid input: '&' 0x3ff) invalid input: '<'invalid input: '<' 10 | (R invalid input: '&' 0x3ff) invalid input: '<'invalid input: '<' 20 | (A invalid input: '&' 0x3) invalid input: '<'invalid input: '<' 30;

  - ### RGBX_8888

    public static final Bitmap.Format RGBX_8888
    RGB, four channels, 8-bit unsigned per channel. Basic data type: byte.

         0       1       2       3       4  byte
         |   r   |   g   |   b   |   x   |

    This format has the same memory layout as `RGBA_8888`, but the alpha channel is always filled with 0xFF and/or considered opaque. This may be faster than `RGB_888` when doing pixel operations.

  - ### BGRA_8888

    public static final Bitmap.Format BGRA_8888
    RGB, with alpha, four channels, 8-bit unsigned per channel. Basic data type: byte.

         0       1       2       3       4  byte
         |   b   |   g   |   r   |   a   |

  - ### ABGR_8888

    @Experimental public static final Bitmap.Format ABGR_8888
    RGB, with alpha, four channels, 8-bit unsigned per channel. Basic data type: byte.

         0       1       2       3       4  byte
         |   a   |   b   |   g   |   r   |

  - ### ARGB_8888

    @Experimental public static final Bitmap.Format ARGB_8888
    RGB, with alpha, four channels, 8-bit unsigned per channel. Basic data type: byte.

         0       1       2       3       4  byte
         |   a   |   r   |   g   |   b   |

  - ### RGBA_8888_PACK32

    @Experimental public static final Bitmap.Format RGBA_8888_PACK32
    RGB, with alpha, packed four channels, 32-bit unsigned per pixel. Basic data type: int.

         0  2  4  6  8 10 12 14 16 18 20 22 24 26 28 30 32  bit
         |     r     |     g     |     b     |     a     |

         int color = (R invalid input: '&' 0xff) | (G invalid input: '&' 0xff) invalid input: '<'invalid input: '<' 8 | (B invalid input: '&' 0xff) invalid input: '<'invalid input: '<' 16 | (A invalid input: '&' 0xff) invalid input: '<'invalid input: '<' 24;

    On little-endian machine, this is the same as `RGBA_8888`. On big-endian machine, this is the same as `ABGR_8888`.

  - ### BGRA_8888_PACK32

    public static final Bitmap.Format BGRA_8888_PACK32
    RGB, with alpha, packed four channels, 32-bit unsigned per pixel. Basic data type: int.

         0  2  4  6  8 10 12 14 16 18 20 22 24 26 28 30 32  bit
         |     b     |     g     |     r     |     a     |

         int color = (B invalid input: '&' 0xff) | (G invalid input: '&' 0xff) invalid input: '<'invalid input: '<' 8 | (R invalid input: '&' 0xff) invalid input: '<'invalid input: '<' 16 | (A invalid input: '&' 0xff) invalid input: '<'invalid input: '<' 24;

    On little-endian machine, this is the same as `BGRA_8888`. On big-endian machine, this is the same as `ARGB_8888`. This is actually used for int values that marked as `ColorInt`.

- ## Method Details

  - ### values

    public static Bitmap.Format[] values()
    Returns an array containing the constants of this enum class, in the order they are declared.
    Returns:
      an array containing the constants of this enum class, in the order they are declared

  - ### valueOf

    public static Bitmap.Format valueOf(String name)
    Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
    Parameters:
      `name` - the name of the enum constant to be returned.
    Returns:
      the enum constant with the specified name
    Throws:
      `IllegalArgumentException` - if this enum class has no constant with the specified name
      `NullPointerException` - if the argument is null

  - ### getChannels

    public int getChannels()
    Returns the number of channels.

  - ### getColorType

    public int getColorType()
    The source (in CPU memory) color type of this format.

    RGB is special, it's 3 bytes per pixel in CPU memory, but 4 bytes per pixel in GPU memory (implicitly).

    See Also:
      - `getBytesPerPixel()`

  - ### getBytesPerPixel

    public int getBytesPerPixel()

  - ### isChannelU8

    public boolean isChannelU8()
    Is this format 8-bit per channel and encoded as unsigned byte?

  - ### isChannelU16

    public boolean isChannelU16()
    Is this format 16-bit per channel and encoded as unsigned short?

  - ### isChannelHDR

    public boolean isChannelHDR()
    Is this format 32-bit per channel and encoded as float?

  - ### hasAlpha

    public boolean hasAlpha()
    Does this format have alpha channel?