Enum Class PixelFormat

java.lang.Object
java.lang.Enum<PixelFormat>
cloud.opencode.base.image.core.PixelFormat
All Implemented Interfaces:
Serializable, Comparable<PixelFormat>, Constable

public enum PixelFormat extends Enum<PixelFormat>
High-level pixel format describing in-memory pixel layout. 高层像素格式,描述内存中的像素布局。

Each value carries the number of bytes per pixel (bpp) and channel order. Used by Raster for pixel addressing and bulk operations.

每个枚举值携带每像素字节数(bpp)和通道顺序。Raster 使用其 进行像素寻址和批量操作。

Note: this is a high-level semantic enum and is intentionally distinct from cloud.opencode.base.image.codec.color.PixelFormat, which is a low-level lcms2 native-encoding constant set.

注意:这是高层语义枚举,刻意与 cloud.opencode.base.image.codec.color.PixelFormat (底层 lcms2 native 编码常量集)区分。

Thread safety | 线程安全: Yes — immutable enum. 是 — 不可变枚举。

Since:
JDK 25, opencode-base-image V1.0.4
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    24-bit BGR, 3 bytes per pixel (B, G, R). | 24 位 BGR,每像素 3 字节(B、G、R)。
    32-bit BGRA, 4 bytes per pixel (B, G, R, A). | 32 位 BGRA,每像素 4 字节(B、G、R、A)。
    8-bit grayscale, 1 byte per pixel. | 8 位灰度,每像素 1 字节。
    8-bit grayscale + 8-bit alpha, 2 bytes per pixel. | 8 位灰度 + 8 位 alpha,每像素 2 字节。
    24-bit RGB, 3 bytes per pixel (R, G, B). | 24 位 RGB,每像素 3 字节(R、G、B)。
    32-bit RGBA, 4 bytes per pixel (R, G, B, A). | 32 位 RGBA,每像素 4 字节(R、G、B、A)。
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of bytes occupied by one pixel of this format.
    int
    Returns the number of channels in this format.
    boolean
    Whether this format carries an alpha channel.
    Returns the enum constant of this class with the specified name.
    static PixelFormat[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • GRAY_8

      public static final PixelFormat GRAY_8
      8-bit grayscale, 1 byte per pixel. | 8 位灰度,每像素 1 字节。
    • GRAY_ALPHA_8

      public static final PixelFormat GRAY_ALPHA_8
      8-bit grayscale + 8-bit alpha, 2 bytes per pixel. | 8 位灰度 + 8 位 alpha,每像素 2 字节。
    • RGB_8

      public static final PixelFormat RGB_8
      24-bit RGB, 3 bytes per pixel (R, G, B). | 24 位 RGB,每像素 3 字节(R、G、B)。
    • RGBA_8

      public static final PixelFormat RGBA_8
      32-bit RGBA, 4 bytes per pixel (R, G, B, A). | 32 位 RGBA,每像素 4 字节(R、G、B、A)。
    • BGR_8

      public static final PixelFormat BGR_8
      24-bit BGR, 3 bytes per pixel (B, G, R). | 24 位 BGR,每像素 3 字节(B、G、R)。
    • BGRA_8

      public static final PixelFormat BGRA_8
      32-bit BGRA, 4 bytes per pixel (B, G, R, A). | 32 位 BGRA,每像素 4 字节(B、G、R、A)。
  • Method Details

    • values

      public static PixelFormat[] 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 PixelFormat 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
    • bytesPerPixel

      public int bytesPerPixel()
      Returns the number of bytes occupied by one pixel of this format. 返回此格式下单像素所占字节数。
      Returns:
      bytes per pixel | 每像素字节数
    • channelCount

      public int channelCount()
      Returns the number of channels in this format. 返回此格式的通道数。
      Returns:
      channel count | 通道数
    • hasAlpha

      public boolean hasAlpha()
      Whether this format carries an alpha channel. 此格式是否带有 alpha 通道。
      Returns:
      true for RGBA_8, BGRA_8, GRAY_ALPHA_8; false otherwise | 对 RGBA_8BGRA_8GRAY_ALPHA_8 返回 true, 其余返回 false