Class PngConstants


  • public abstract class PngConstants
    extends java.lang.Object
    This interface defines all registered chunk types and provides methods helper methods to examine them. It also defines all of the keys used in the property map of a decoded PngImage, and applicable enumerated values.
    See Also:
    PngImage.getProperty(java.lang.String), PngImage.getProperties()
    • Constructor Detail

      • PngConstants

        public PngConstants()
    • Method Detail

      • isAncillary

        public static boolean isAncillary​(int chunkType)
        Returns true if the given chunk type has the ancillary bit set (the first letter is lowercase). An ancillary chunk is once which is not strictly necessary in order to meaningfully display the contents of the file.
        Parameters:
        chunkType - the chunk type
        Returns:
        whether the chunk type ancillary bit is set
      • isPrivate

        public static boolean isPrivate​(int chunkType)
        Returns true if the given chunk type has the private bit set (the second letter is lowercase). All unregistered chunk types should have this bit set.
        Parameters:
        chunkType - the chunk type
        Returns:
        whether the chunk type private bit is set
      • isReserved

        public static boolean isReserved​(int chunkType)
        Returns true if the given chunk type has the reserved bit set (the third letter is lowercase). The meaning of this bit is currently undefined, but reserved for future use. Images conforming to the current version of the PNG specification must not have this bit set.
        Parameters:
        chunkType - the chunk type
        Returns:
        whether the chunk type reserved bit is set
      • isSafeToCopy

        public static boolean isSafeToCopy​(int chunkType)
        Returns true if the given chunk type has the safe-to-copy bit set (the fourth letter is lowercase). Chunks marked as safe-to-copy may be copied to a modified PNG file whether or not the software recognizes the chunk type.
        Parameters:
        chunkType - the chunk type
        Returns:
        whether the chunk safe-to-copy bit is set
      • getChunkName

        public static java.lang.String getChunkName​(int chunkType)
        Returns the four-character ASCII name corresponding to the given chunk type. For example, PngConstants.getChunkName(PngConstants.IHDR) will return "IHDR".
        Parameters:
        chunkType - the chunk type
        Returns:
        the four-character ASCII chunk name
      • getChunkType

        public static int getChunkType​(java.lang.String chunkName)
        Returns the chunk type corresponding to the given four-character ASCII chunk name.
        Parameters:
        chunkName - the four-character ASCII chunk name
        Returns:
        the chunk type
        Throws:
        java.lang.NullPointerException - if name is null
        java.lang.IndexOutOfBoundsException - if name has less than four characters