Package com.comphenix.protocol.wrappers
Class WrappedServerPing.CompressedImage
java.lang.Object
com.comphenix.protocol.wrappers.WrappedServerPing.CompressedImage
- Enclosing class:
WrappedServerPing
Represents a compressed favicon.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRepresents a compressed image with no content.CompressedImage(String mime, byte[] data) Construct a new compressed image. -
Method Summary
Modifier and TypeMethodDescriptionfromBase64Png(String base64) Retrieve a compressed image from a base-64 encoded PNG file.fromEncodedText(String text) Retrieve a compressed image from an encoded text.fromPng(byte[] data) Retrieve a compressed image from a byte array of a PNG file.fromPng(RenderedImage image) Retrieve a compressed image from an image.fromPng(InputStream input) Retrieve a compressed image from an input stream.protected byte[]getData()Retrieve the underlying data, with no copying.byte[]Retrieve a copy of the underlying data array.getImage()Uncompress and return the stored image.getMime()Retrieve the MIME type of the image.Convert the compressed image to encoded text.
-
Field Details
-
mime
-
data
protected volatile byte[] data -
encoded
-
-
Constructor Details
-
CompressedImage
protected CompressedImage()Represents a compressed image with no content. -
CompressedImage
Construct a new compressed image.- Parameters:
mime- - the mime type.data- - the raw compressed image data.
-
-
Method Details
-
fromPng
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
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
Retrieve a compressed image from a base-64 encoded PNG file.- Parameters:
base64- - the base 64-encoded PNG.- Returns:
- The compressed image.
-
fromPng
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
Retrieve a compressed image from an encoded text.- Parameters:
text- - the encoded text.- Returns:
- The corresponding compressed image.
-
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
Uncompress and return the stored image.- Returns:
- The image.
- Throws:
IOException- If the image data could not be decoded.
-
toEncodedText
Convert the compressed image to encoded text.- Returns:
- The encoded text.
-