Enum Class PixelFormat
- All Implemented Interfaces:
Serializable, Comparable<PixelFormat>, Constable
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 ConstantsEnum ConstantDescription24-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 TypeMethodDescriptionintReturns the number of bytes occupied by one pixel of this format.intReturns the number of channels in this format.booleanhasAlpha()Whether this format carries an alpha channel.static PixelFormatReturns the enum constant of this class with the specified name.static PixelFormat[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
GRAY_8
8-bit grayscale, 1 byte per pixel. | 8 位灰度,每像素 1 字节。 -
GRAY_ALPHA_8
8-bit grayscale + 8-bit alpha, 2 bytes per pixel. | 8 位灰度 + 8 位 alpha,每像素 2 字节。 -
RGB_8
24-bit RGB, 3 bytes per pixel (R, G, B). | 24 位 RGB,每像素 3 字节(R、G、B)。 -
RGBA_8
32-bit RGBA, 4 bytes per pixel (R, G, B, A). | 32 位 RGBA,每像素 4 字节(R、G、B、A)。 -
BGR_8
24-bit BGR, 3 bytes per pixel (B, G, R). | 24 位 BGR,每像素 3 字节(B、G、R)。 -
BGRA_8
32-bit BGRA, 4 bytes per pixel (B, G, R, A). | 32 位 BGRA,每像素 4 字节(B、G、R、A)。
-
-
Method Details
-
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
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 nameNullPointerException- 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:
trueforRGBA_8,BGRA_8,GRAY_ALPHA_8;falseotherwise | 对RGBA_8、BGRA_8、GRAY_ALPHA_8返回true, 其余返回false
-