Class Encode
java.lang.Object
is.galia.operation.Encode
- All Implemented Interfaces:
Operation
Encapsulates an image encoding operation.
Typically appears at the very end of an OperationList.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAny key supplied tosetOption(String, Object)must start with this string. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfreeze()Makes the instance unmodifiable.intgetXMP()booleanSimpler but less-accurate counterpart ofOperation.hasEffect(Size, OperationList).booleanhasEffect(Size fullSize, OperationList opList) Context-aware counterpart toOperation.hasEffect().voidremoveOption(String key) voidsetBackgroundColor(Color color) voidvoidsetMaxComponentSize(int depth) voidsetNativeMetadata(NativeMetadata metadata) voidSome encoders may support their own custom encoding options.voidtoMap(Size fullSize, ScaleConstraint scaleConstraint) Returns a map in the following format:toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface is.galia.operation.Operation
getResultingSize, validate
-
Field Details
-
OPTION_PREFIX
Any key supplied tosetOption(String, Object)must start with this string.- See Also:
-
-
Constructor Details
-
Encode
-
-
Method Details
-
freeze
public void freeze()Description copied from interface:OperationMakes the instance unmodifiable. When frozen, mutation methods should throw anIllegalStateExceptionand getters should return immutable values, if possible. (But they should do that anyway.) -
getBackgroundColor
- Returns:
- Color with which to fill the empty portions of the image when
getFormat()returns a format that does not support transparency and when either rotating by a non-90-degree multiple, or when flattening an image with alpha. May benull.
-
getFormat
-
getMaxComponentSize
public int getMaxComponentSize()- Returns:
- Maximum sample size to encode. May be
Integer.MAX_VALUEindicating no max.
-
getNativeMetadata
- Returns:
- Native metadata.
-
getOptions
- Returns:
- Unmodifiable options.
- See Also:
-
getXMP
-
hasEffect
public boolean hasEffect()Description copied from interface:OperationSimpler but less-accurate counterpart ofOperation.hasEffect(Size, OperationList). -
hasEffect
Description copied from interface:OperationContext-aware counterpart toOperation.hasEffect(). For example, a scale operation specifying a scale to 300×200, when the given operation list contains a crop of 300×200, would returnfalse. -
removeOption
- Throws:
IllegalStateException- if the instance is frozen.
-
setBackgroundColor
- Parameters:
color- Background color.- Throws:
IllegalStateException- if the instance is frozen.
-
setFormat
- Parameters:
format- Format to set.- Throws:
IllegalStateException- if the instance is frozen.
-
setMaxComponentSize
public void setMaxComponentSize(int depth) - Parameters:
depth- Maximum sample size to encode. Supply0to indicate no max.- Throws:
IllegalStateException- if the instance is frozen.
-
setNativeMetadata
- Parameters:
metadata- Native metadata.- Throws:
IllegalStateException- if the instance is frozen.
-
setOption
Some encoders may support their own custom encoding options. Rather than forcing them to draw this information directly from the application configuration, which would make it invisible in the operation pipeline (and therefore not considered in e.g. variant image cache keys), these options can be supplied here, where they will affect the output of
toString()andtoMap(is.galia.image.Size, is.galia.image.ScaleConstraint).- Parameters:
key- Option key, which must start withOPTION_PREFIX. No other constraints are imposed, but as keys are drawn from the application configuration, they should align with that syntax.value- Option value.- Throws:
IllegalArgumentException- if the key does not conform to the required syntax.IllegalStateException- if the instance is frozen.- See Also:
-
setXMP
- Parameters:
xmp- Embeddable XMP metadata.rdf:RDFis the enclosing tag.- Throws:
IllegalStateException- if the instance is frozen.
-
toMap
Returns a map in the following format:
{ class: "Encode" background_color: Hexadecimal string format: Media type string max_sample_size: Integer native_metadata: SeeNativeMetadata.toMap()xmp: String options: { key1: value key2: value } } -
toString
-