Record Class WebpOptions

java.lang.Object
java.lang.Record
cloud.opencode.base.image.codec.webp.WebpOptions
Record Components:
lossless - if true use libwebp's lossless encoder; otherwise lossy | 为 true 时使用无损编码器;否则使用有损编码器
quality - perceptual quality factor in [0, 100] (lossy only) | 感知质量因子,范围 [0, 100](仅有损)

public record WebpOptions(boolean lossless, float quality) extends Record
Encoding options for WebpCodec encode operations. WebpCodec 编码操作的编码选项。

Two modes are supported:

  • Lossy (when lossless == false): quality drives libwebp's perceptual encoder, range [0, 100]. - 有损:lossless == false 时,quality 驱动 libwebp 感知编码器, 范围 [0, 100]
  • Lossless (when lossless == true): pixel-perfect encode; quality is ignored by libwebp's lossless API. - 无损:lossless == true 时,按像素无损编码;libwebp 无损 API 忽略 quality

Security | 安全性:

  • Thread-safe: Yes - record is immutable. - 线程安全: 是 - record 不可变。
  • Bounds-checked: quality must be in [0, 100]. - 边界检查: quality 必须在 [0, 100] 范围内。
Since:
JDK 25, opencode-base-image-codec V1.0.4
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    WebpOptions(boolean lossless, float quality)
    Compact constructor validating quality range.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns sensible defaults: lossy, quality 75.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the lossless record component.
    Returns lossless preset (quality unused; stored as 100).
    lossy(float quality)
    Returns lossy preset with the given quality.
    float
    Returns the value of the quality record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

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

    • WebpOptions

      public WebpOptions(boolean lossless, float quality)
      Compact constructor validating quality range. 紧凑构造器,校验 quality 范围。
  • Method Details

    • defaults

      public static WebpOptions defaults()
      Returns sensible defaults: lossy, quality 75. 返回常用默认值:有损,quality 75
      Returns:
      default WebpOptions | 默认 WebpOptions
    • losslessDefault

      public static WebpOptions losslessDefault()
      Returns lossless preset (quality unused; stored as 100). 返回无损预设(quality 未使用;存为 100)。

      Named losslessDefault() (not lossless()) to avoid clashing with the record accessor method lossless() which returns boolean.

      命名为 losslessDefault()(而非 lossless())以避免与 record 自动生成的 accessor 方法 lossless() 冲突。

      Returns:
      lossless WebpOptions | 无损 WebpOptions
    • lossy

      public static WebpOptions lossy(float quality)
      Returns lossy preset with the given quality. 返回带指定质量的有损预设。
      Parameters:
      quality - perceptual quality in [0, 100] | 感知质量
      Returns:
      lossy WebpOptions | 有损 WebpOptions
    • 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. All components in this record class 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.
    • lossless

      public boolean lossless()
      Returns the value of the lossless record component.
      Returns:
      the value of the lossless record component
    • quality

      public float quality()
      Returns the value of the quality record component.
      Returns:
      the value of the quality record component