Record Class JpegOptions

java.lang.Object
java.lang.Record
cloud.opencode.base.image.codec.jpeg.JpegOptions
Record Components:
quality - JPEG quality factor in [1, 100], where higher is better quality and larger file. | JPEG 质量因子,范围 [1, 100], 数值越大质量越好、文件越大。
subsampling - chroma subsampling mode | 色度下采样模式

public record JpegOptions(int quality, JpegSubsampling subsampling) extends Record
Encoding options for JpegCodec.encode(byte[], int, int, JpegOptions). JpegCodec.encode(byte[], int, int, JpegOptions) 的编码选项。

Holds the JPEG quality factor (1-100) and chroma subsampling mode.

持有 JPEG 质量因子(1-100)和色度下采样模式。

Security | 安全性:

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

    • JpegOptions

      public JpegOptions(int quality, JpegSubsampling subsampling)
      Compact constructor validating quality and subsampling. 紧凑构造器,校验 qualitysubsampling
  • Method Details

    • defaults

      public static JpegOptions defaults()
      Returns sensible defaults: quality 75, subsampling 4:2:0. 返回常用默认值:quality 75,subsampling 4:2:0
      Returns:
      default JpegOptions | 默认 JpegOptions
    • highQuality

      public static JpegOptions highQuality()
      Returns high-quality preset: quality 95, subsampling 4:4:4. 返回高质量预设:quality 95,subsampling 4:4:4
      Returns:
      high-quality JpegOptions | 高质量 JpegOptions
    • 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.
    • quality

      public int quality()
      Returns the value of the quality record component.
      Returns:
      the value of the quality record component
    • subsampling

      public JpegSubsampling subsampling()
      Returns the value of the subsampling record component.
      Returns:
      the value of the subsampling record component