Package com.sixlegs.png
Class PngConfig.Builder
- java.lang.Object
-
- com.sixlegs.png.PngConfig.Builder
-
- Enclosing class:
- PngConfig
public static final class PngConfig.Builder extends java.lang.ObjectBuilder class used to constructPngConfiginstances. Each "setter" method returns an reference to the instance to enable chaining multiple calls. Callbuild()to construct a newPngConfiginstance using the currentBuildersettings. Example:PngConfig config = new PngConfig.Builder() .readLimit(PngConfig.READ_EXCEPT_METADATA) .warningsFatal(true) .build();
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PngConfigbuild()Create a configuration using the current values of this builder.PngConfig.BuilderconvertIndexed(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.PngConfig.BuilderdefaultGamma(float defaultGamma)Sets the default gamma value.PngConfig.BuilderdisplayExponent(float displayExponent)Sets the default display exponent.PngConfig.BuildergammaCorrect(boolean gammaCorrect)Enables or disables gamma correction.PngConfig.Builderprogressive(boolean progressive)Enables or disables progressive display for interlaced images.PngConfig.BuilderreadLimit(int readLimit)Configures how much of the image to read.PngConfig.Builderreduce16(boolean reduce16)Enables or disables 16-bit reduction.PngConfig.BuildersourceRegion(java.awt.Rectangle sourceRegion)Decode only a particular region of the source image.PngConfig.BuildersourceSubsampling(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.PngConfig.BuilderwarningsFatal(boolean warningsFatal)Configures whether warnings should be treated as fatal errors.
-
-
-
Constructor Detail
-
Builder
public Builder()
Create a new builder using default values.
-
Builder
public Builder(PngConfig cfg)
Create a builder using values from the given configuration.- Parameters:
cfg- the configuration to copy
-
-
Method Detail
-
build
public PngConfig build()
Create a configuration using the current values of this builder.
-
reduce16
public PngConfig.Builder reduce16(boolean 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
public PngConfig.Builder defaultGamma(float 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
public PngConfig.Builder displayExponent(float 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
public PngConfig.Builder gammaCorrect(boolean 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:
PngImage.getGamma(),PngImage.getGammaTable()
-
progressive
public PngConfig.Builder progressive(boolean 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:
PngImage.handlePass(java.awt.image.BufferedImage, int)
-
readLimit
public PngConfig.Builder readLimit(int 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
public PngConfig.Builder warningsFatal(boolean warningsFatal)
Configures whether warnings should be treated as fatal errors. All non-fatalPngExceptionexceptions 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:
PngImage.handleWarning(com.sixlegs.png.PngException)
-
sourceRegion
public PngConfig.Builder sourceRegion(java.awt.Rectangle sourceRegion)
Decode only a particular region of the source image. See the equivalent ImageIO method for full documentation.
-
sourceSubsampling
public PngConfig.Builder 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. See the equivalent ImageIO method for full documentation.
-
convertIndexed
public PngConfig.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.
-
-