Package com.sixlegs.png
Class PngConfig.Builder
java.lang.Object
com.sixlegs.png.PngConfig.Builder
- Enclosing class:
PngConfig
Builder class used to construct
PngConfig
instances.
Each "setter" method returns an reference to the instance to enable
chaining multiple calls.
Call build()
to construct a new PngConfig
instance
using the current Builder
settings. Example:
PngConfig config = new PngConfig.Builder() .readLimit(PngConfig.READ_EXCEPT_METADATA) .warningsFatal(true) .build();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Create a configuration using the current values of this builder.convertIndexed
(boolean convertIndexed) Whether to convert images with an indexed color model (paletted and 1/2/4/8-bit grayscale) to use a component color model.defaultGamma
(float defaultGamma) Sets the default gamma value.displayExponent
(float displayExponent) Sets the default display exponent.gammaCorrect
(boolean gammaCorrect) Enables or disables gamma correction.progressive
(boolean progressive) Enables or disables progressive display for interlaced images.readLimit
(int readLimit) Configures how much of the image to read.reduce16
(boolean reduce16) Enables or disables 16-bit reduction.sourceRegion
(Rectangle sourceRegion) Decode only a particular region of the source image.sourceSubsampling
(int xsub, int ysub, int xoff, int yoff) Reduce the size of the decoded image (or source region) by only using periodic rows and/or columns of the image.warningsFatal
(boolean warningsFatal) Configures whether warnings should be treated as fatal errors.
-
Constructor Details
-
Builder
public Builder()Create a new builder using default values. -
Builder
Create a builder using values from the given configuration.- Parameters:
cfg
- the configuration to copy
-
-
Method Details
-
build
Create a configuration using the current values of this builder. -
reduce16
Enables or disables 16-bit reduction. If enabled, 16-bit samples are reduced to 8-bit samples by shifting to the right by 8 bits. Default is true.- Parameters:
reduce16
- enable 16-bit reduction
-
defaultGamma
Sets the default gamma value. This value is used unless the image contains an explicit gamma value. Initial value is 1/45455.- Parameters:
defaultGamma
- the default gamma value
-
displayExponent
Sets the default display exponent. The proper setting depends on monitor and OS gamma lookup table settings, if any. The default value of 2.2 should work well with most PC displays. If the operating system has a gamma lookup table (e.g. Macintosh) the display exponent should be lower.- Parameters:
displayExponent
- the display exponent
-
gammaCorrect
Enables or disables gamma correction. If enabled, decoded images will be gamma corrected. Sets to false if your application will perform gamma correctly manually. Default is true.- Parameters:
gammaCorrect
- use gamma correction- See Also:
-
progressive
Enables or disables progressive display for interlaced images. If enabled, each received pixel is expanded (replicated) to fill a rectangle covering the yet-to-be-transmitted pixel positions below and to the right of the received pixel. This produces a "fade-in" effect as the new image gradually replaces the old, at the cost of some additional processing time. Default is false.- Parameters:
progressive
- use progressive display- See Also:
-
readLimit
Configures how much of the image to read. Useful when one is interested in only a portion of the image metadata, and would like to avoid reading and/or decoding the actual image data.- Parameters:
readLimit
-READ_ALL
,
READ_HEADER
,
READ_UNTIL_DATA
,
READ_EXCEPT_DATA
,
orREAD_EXCEPT_METADATA
-
warningsFatal
Configures whether warnings should be treated as fatal errors. All non-fatalPngException
exceptions are caught and passed to thePngImage.handleWarning(com.sixlegs.png.PngException)
method. If warnings are configured as fatal, that method will re-throw the exception, which will abort image processing. Default is false.- Parameters:
warningsFatal
- true if warnings should be treated as fatal errors- See Also:
-
sourceRegion
Decode only a particular region of the source image. See the equivalent ImageIO method for full documentation. -
sourceSubsampling
Reduce the size of the decoded image (or source region) by only using periodic rows and/or columns of the image. See the equivalent ImageIO method for full documentation. -
convertIndexed
Whether to convert images with an indexed color model (paletted and 1/2/4/8-bit grayscale) to use a component color model.
-