Record Class ImageFormat
- Record Components:
mediaType- lower-case IANA media type, e.g."image/png"
Images.encode(Image, ImageFormat) for and what an ImageEncoder
declares it can produce.
Deliberately a value and not an enum. A format is contributed by whichever
encoder is installed, so a closed set would mean that adding JPEG or WebP
required a toolkit release even though nothing in the toolkit would encode it.
The price is that a misspelled media type is a runtime failure ("no encoder
accepts …") rather than a compile error, which is why PNG is a
constant: the one format the toolkit itself always provides never has to be
spelled out.
The media type is the identity. It is trimmed and lower-cased on
construction, so new ImageFormat("IMAGE/PNG") equals PNG, and
an encoder may compare with equals rather than parsing the string.
Parameters are not understood: "image/png; foo=bar" is a different
format from "image/png" and nothing will accept it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ImageFormatPortable Network Graphics: lossless, 8-bit RGBA with straight alpha, which is exactlyImage's pixel contract, so a PNG round trip through this toolkit is bit-exact. -
Constructor Summary
ConstructorsConstructorDescriptionImageFormat(String mediaType) Creates an instance of aImageFormatrecord class. -
Method Summary
-
Field Details
-
PNG
Portable Network Graphics: lossless, 8-bit RGBA with straight alpha, which is exactlyImage's pixel contract, so a PNG round trip through this toolkit is bit-exact. Always encodable: the toolkit's own encoder is installed without a backend (seeImages.installEncoder(limn.graphics.ImageEncoder)).
-
-
Constructor Details
-
ImageFormat
Creates an instance of aImageFormatrecord class.- Parameters:
mediaType- the value for themediaTyperecord component
-
-
Method Details
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
mediaType
Returns the value of themediaTyperecord component.- Returns:
- the value of the
mediaTyperecord component
-