Class PNGDecoder

java.lang.Object
zombie.core.textures.PNGDecoder

public final class PNGDecoder extends Object
A PNGDecoder. The slick PNG decoder is based on this class :)
  • Field Details

    • maskID

      public int maskID
    • mask

      public BooleanGrid mask
    • bDoMask

      public boolean bDoMask
    • readTotal

      public long readTotal
  • Constructor Details

  • Method Details

    • getHeight

      public int getHeight()
    • getWidth

      public int getWidth()
    • hasAlphaChannel

      public boolean hasAlphaChannel()
      Checks if the image has a real alpha channel. This method does not check for the presence of a tRNS chunk.
      Returns:
      true if the image has an alpha channel
      See Also:
    • hasAlpha

      public boolean hasAlpha()
      Checks if the image has transparency information either from an alpha channel or from a tRNS chunk.
      Returns:
      true if the image has transparency
      See Also:
    • isRGB

      public boolean isRGB()
    • overwriteTRNS

      public void overwriteTRNS(byte r, byte g, byte b)
      Overwrites the tRNS chunk entry to make a selected color transparent.

      This can only be invoked when the image has no alpha channel.

      Calling this method causes hasAlpha() to return true.

      Parameters:
      r - the red component of the color to make transparent
      g - the green component of the color to make transparent
      b - the blue component of the color to make transparent
      Throws:
      UnsupportedOperationException - if the tRNS chunk data can't be set
      See Also:
    • decideTextureFormat

      public PNGDecoder.Format decideTextureFormat(PNGDecoder.Format fmt)
      Computes the implemented format conversion for the desired format.
      Parameters:
      fmt - the desired format
      Returns:
      format which best matches the desired format
      Throws:
      UnsupportedOperationException - if this PNG file can't be decoded
    • decode

      public void decode(ByteBuffer buffer, int stride, PNGDecoder.Format fmt) throws IOException
      Decodes the image into the specified buffer. The first line is placed at the current position. After decode the buffer position is at the end of the last line.
      Parameters:
      buffer - the buffer
      stride - the stride in bytes from start of a line to start of the next line, can be negative.
      fmt - the target format into which the image should be decoded.
      Throws:
      IOException - if a read or data error occurred
      IllegalArgumentException - if the start position of a line falls outside the buffer
      UnsupportedOperationException - if the image can't be decoded into the desired format
    • decodeFlipped

      public void decodeFlipped(ByteBuffer buffer, int stride, PNGDecoder.Format fmt) throws IOException
      Decodes the image into the specified buffer. The last line is placed at the current position. After decode the buffer position is at the end of the first line.
      Parameters:
      buffer - the buffer
      stride - the stride in bytes from start of a line to start of the next line, must be positive.
      fmt - the target format into which the image should be decoded.
      Throws:
      IOException - if a read or data error occurred
      IllegalArgumentException - if the start position of a line falls outside the buffer
      UnsupportedOperationException - if the image can't be decoded into the desired format