Class PngConfig.Builder

  • Enclosing class:
    PngConfig

    public static final class PngConfig.Builder
    extends Object
    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 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)
      • 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.