Class WrappedServerPing.CompressedImage

java.lang.Object
com.comphenix.protocol.wrappers.WrappedServerPing.CompressedImage
Enclosing class:
WrappedServerPing

public static class WrappedServerPing.CompressedImage extends Object
Represents a compressed favicon.
  • Field Details

    • mime

      protected volatile String mime
    • data

      protected volatile byte[] data
    • encoded

      protected volatile String encoded
  • Constructor Details

    • CompressedImage

      protected CompressedImage()
      Represents a compressed image with no content.
    • CompressedImage

      public CompressedImage(String mime, byte[] data)
      Construct a new compressed image.
      Parameters:
      mime - - the mime type.
      data - - the raw compressed image data.
  • Method Details

    • fromPng

      public static WrappedServerPing.CompressedImage fromPng(InputStream input) throws IOException
      Retrieve a compressed image from an input stream.
      Parameters:
      input - - the PNG as an input stream.
      Returns:
      The compressed image.
      Throws:
      IOException - If we cannot read the input stream.
    • fromPng

      public static WrappedServerPing.CompressedImage fromPng(byte[] data)
      Retrieve a compressed image from a byte array of a PNG file.
      Parameters:
      data - - the file as a byte array.
      Returns:
      The compressed image.
    • fromBase64Png

      public static WrappedServerPing.CompressedImage fromBase64Png(String base64)
      Retrieve a compressed image from a base-64 encoded PNG file.
      Parameters:
      base64 - - the base 64-encoded PNG.
      Returns:
      The compressed image.
    • fromPng

      public static WrappedServerPing.CompressedImage fromPng(RenderedImage image) throws IOException
      Retrieve a compressed image from an image.
      Parameters:
      image - - the image.
      Returns:
      A compressed image from an image.
      Throws:
      IOException - If we were unable to compress the image.
    • fromEncodedText

      public static WrappedServerPing.CompressedImage fromEncodedText(String text)
      Retrieve a compressed image from an encoded text.
      Parameters:
      text - - the encoded text.
      Returns:
      The corresponding compressed image.
    • getMime

      public String getMime()
      Retrieve the MIME type of the image.

      This is image/png in vanilla Minecraft.

      Returns:
      The MIME type.
    • getDataCopy

      public byte[] getDataCopy()
      Retrieve a copy of the underlying data array.
      Returns:
      The underlying compressed image.
    • getData

      protected byte[] getData()
      Retrieve the underlying data, with no copying.
      Returns:
      The underlying data.
    • getImage

      public BufferedImage getImage() throws IOException
      Uncompress and return the stored image.
      Returns:
      The image.
      Throws:
      IOException - If the image data could not be decoded.
    • toEncodedText

      public String toEncodedText()
      Convert the compressed image to encoded text.
      Returns:
      The encoded text.