java.lang.Object
de.gurkenlabs.litiengine.util.io.Codec

public final class Codec
extends java.lang.Object
  • Method Summary

    Modifier and TypeMethodDescription
    static byte[]decode​(java.lang.String base64)
    Decodes the specified Base64 string to a byte array.
    static floatdecodeAngle​(byte encodedAngle)
    Decodes a previously encoded angle.
    static floatdecodeAngle​(short encodedAngle) 
    static java.awt.image.BufferedImagedecodeImage​(java.lang.String imageString) 
    static floatdecodeSmallFloatingPointNumber​(short encodedNumber, int precision)
    Decodes a small floating point number, previously encoded with encodeSmallFloatingPointNumber.
    static java.lang.Stringencode​(byte[] data) 
    static java.lang.Stringencode​(java.awt.image.BufferedImage image) 
    static java.lang.Stringencode​(java.awt.image.BufferedImage image, ImageFormat imageFormat) 
    static byteencodeAngle​(float angle)
    Encodes an angle, loosing some precision.
    static shortencodeAnglePrecise​(float angle) 
    static shortencodeSmallFloatingPointNumber​(float smallNumber, int precision)
    Encodes positive numbers less than Short.MAX_VALUE * 2 / precision (6553.4 for precision = 1).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • decodeAngle

      public static float decodeAngle​(byte encodedAngle)
      Decodes a previously encoded angle.
      Parameters:
      encodedAngle - The encoded angle.
      Returns:
      The decoded angle.
    • decodeAngle

      public static float decodeAngle​(short encodedAngle)
    • decodeSmallFloatingPointNumber

      public static float decodeSmallFloatingPointNumber​(short encodedNumber, int precision)
      Decodes a small floating point number, previously encoded with encodeSmallFloatingPointNumber.
      Parameters:
      encodedNumber - The encoded number
      precision - The precision of the encoded number. The same precision, used for encoding.
      Returns:
      The decoded small floating point number.
    • encodeAngle

      public static byte encodeAngle​(float angle)
      Encodes an angle, loosing some precision. The encoded / decoded values can differ at max. around 1.43 degrees from the original one.
      Parameters:
      angle - The angle
      Returns:
      The encoded angle.
    • encodeAnglePrecise

      public static short encodeAnglePrecise​(float angle)
    • encodeSmallFloatingPointNumber

      public static short encodeSmallFloatingPointNumber​(float smallNumber, int precision)
      Encodes positive numbers less than Short.MAX_VALUE * 2 / precision (6553.4 for precision = 1).
      Parameters:
      smallNumber - The small number to encode
      precision - The comma precision for the encoding process.
      Returns:
      The encoded number.
    • decodeImage

      public static java.awt.image.BufferedImage decodeImage​(java.lang.String imageString)
    • encode

      public static java.lang.String encode​(java.awt.image.BufferedImage image)
    • encode

      public static java.lang.String encode​(java.awt.image.BufferedImage image, ImageFormat imageFormat)
    • encode

      public static java.lang.String encode​(byte[] data)
    • decode

      public static byte[] decode​(java.lang.String base64)
      Decodes the specified Base64 string to a byte array.
      Parameters:
      base64 - The Base64 string containing the encoded binary data.
      Returns:
      The decoded byte array.
      See Also:
      Base64