Record Class Bitmap

java.lang.Object
java.lang.Record
cloud.opencode.base.image.codec.font.Bitmap
Record Components:
width - pixel width | 像素宽
height - pixel height | 像素高
alpha - alpha bytes, length = width * height | alpha 字节, 长度 = width * height

public record Bitmap(int width, int height, byte[] alpha) extends Record
Single-channel 8-bit alpha bitmap, row-major, top-down. 单通道 8 位 alpha 位图,行优先,从上到下。

0 = fully transparent, 255 = fully opaque. Composite against any color by multiplying alpha into the target pixel. Produced by Font.rasterizeCodepoint(int, float) and Font.rasterize(String, float).

0 = 完全透明,255 = 完全不透明。可与任意颜色合成 — 将 alpha 乘到目标像素。 由 Font.rasterizeCodepoint(int, float)Font.rasterize(String, float) 产出。

Security | 安全性:

  • Thread-safe: Yes - record with effectively immutable fields (the alpha array reference is final; record components are returned by reference per Java semantics, callers must not mutate). - 线程安全: 是 — record 字段有效不可变(alpha 数组引用为 final; Java 语义按引用返回 record 组件,调用方不应修改)。
  • Bounds-checked: constructor validates dimensions and array length agreement. - 边界检查:构造函数校验尺寸与数组长度一致。
Since:
JDK 25, opencode-base-image-codec V1.0.4
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Bitmap(int width, int height, byte[] alpha)
    Compact constructor validates invariants.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the value of the alpha record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the height record component.
    final String
    Returns a string representation of this record class.
    int
    Returns the value of the width record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Bitmap

      public Bitmap(int width, int height, byte[] alpha)
      Compact constructor validates invariants. 紧凑构造函数校验不变式。
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • width

      public int width()
      Returns the value of the width record component.
      Returns:
      the value of the width record component
    • height

      public int height()
      Returns the value of the height record component.
      Returns:
      the value of the height record component
    • alpha

      public byte[] alpha()
      Returns the value of the alpha record component.
      Returns:
      the value of the alpha record component