Class PixelBit

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int changePixelValue​(int pixelARGB)
      Changes the value of a random color channel (ARGB) of the given pixel by +1 or -1 (randomly, but avoiding overflow).
      byte[] decode​(int bLength)
      Decodes pixels in the sequence provided by the overlay (given to the constructor) according to its algorithm.
      void encode​(byte[] payload)
      Encodes the payload in the sequence of pixels provided by the overlay given to the constructor.
      int getNumberOfChannels()
      Returns the number of color channels this algorithm is currently choosing from to encode data.
      static boolean pixelIsOne​(int pixelARGB)
      In this algorithm, if the return of this function is true, the given pixel represents a bit-value of 1.
      void setNumberOfChannels​(int numberOfChannels)
      Sets the number of color channels this algorithm is choosing from to encode data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PixelBit

        public PixelBit​(PixelCoordinateOverlay overlay)
                 throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
    • Method Detail

      • getNumberOfChannels

        public int getNumberOfChannels()
        Returns the number of color channels this algorithm is currently choosing from to encode data. Cannot be greater than 4 or smaller than 1.
        Returns:
        the number of color channels currently used
      • setNumberOfChannels

        public void setNumberOfChannels​(int numberOfChannels)

        Sets the number of color channels this algorithm is choosing from to encode data. Cannot be greater than 4 or smaller than 1.

        If the value is 1, this algorithm acts as a normal LSB-Encoder.

        • 1: Blue channel
        • 2: Green and Blue channel
        • 3: Red, Green and Blue channel
        • 4: Alpha, Red, Green and Blue channel
        Parameters:
        numberOfChannels - number of channels to use
      • encode

        public void encode​(byte[] payload)
                    throws ImageCapacityException
        Description copied from class: BuffImgEncoder
        Encodes the payload in the sequence of pixels provided by the overlay given to the constructor.
        Specified by:
        encode in class BuffImgEncoder
        Parameters:
        payload - payload or "message" to encode
        Throws:
        ImageCapacityException - if the payload is larger than the available pixels
      • decode

        public byte[] decode​(int bLength)
        Description copied from class: BuffImgEncoder

        Decodes pixels in the sequence provided by the overlay (given to the constructor) according to its algorithm. Returns the result as a byte array.

        Decoding will continue until the byte arrays length is equal to bLength.

        Specified by:
        decode in class BuffImgEncoder
        Parameters:
        bLength - number of bytes to decode
        Returns:
        decoded bytes
      • pixelIsOne

        public static boolean pixelIsOne​(int pixelARGB)

        In this algorithm, if the return of this function is true, the given pixel represents a bit-value of 1. If it is false, the pixel represents a bit-value of 0.

        Returns true, if the sum of the individual bytes of pixelARGB is an uneven number ((A+R+G+B) mod 2 == 1).

        Differently put: It determines whether the amount of 1's in the least significant bits of each individual byte of pixelARGB is uneven.

        Parameters:
        pixelARGB - pixel that represents a bit.
        Returns:
        true if the given pixel represents a 1 bit.
      • changePixelValue

        protected int changePixelValue​(int pixelARGB)

        Changes the value of a random color channel (ARGB) of the given pixel by +1 or -1 (randomly, but avoiding overflow).

        Since a pixel represents a bit, this method "flips" it. (By changing the outcome of (A+R+G+B) & 1 == 0)

        Parameters:
        pixelARGB - the pixelValue to change
        Returns:
        the changed pixelValue