Class ImageStegIOJava

  • All Implemented Interfaces:
    ImageStegIO

    public class ImageStegIOJava
    extends java.lang.Object
    implements ImageStegIO
    This Class exists to handle reading and writing of BufferedImages to and from byte arrays as well as choosing the appropriate encoders (and their overlays) for the given image. It holds on to the image during its en- or decoding.
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageStegIOJava​(byte[] image, boolean useTransparent)
      Creates an object that exists to handle reading and writing of BufferedImages to and from byte arrays as well as choosing the appropriate encoders (and their overlays) for the given image.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BuffImgEncoder getEncoder​(long seed)
      Determines and returns the suitable encoder (and overlay) for the image according to its type.
      java.lang.String getFormat()
      Returns the images format.
      byte[] getImageAsByteArray()
      Returns the image in its current state (Output-Image) as a byte Array.
      protected PixelCoordinateOverlay getOverlay​(java.awt.image.BufferedImage bufferedImage, long seed)
      Returns an overlay according to the global variable useTransparent
      • Methods inherited from class java.lang.Object

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

      • ImageStegIOJava

        public ImageStegIOJava​(byte[] image,
                               boolean useTransparent)

        Creates an object that exists to handle reading and writing of BufferedImages to and from byte arrays as well as choosing the appropriate encoders (and their overlays) for the given image. It holds on to the image during its en- or decoding.

        The image will only be processed if the methods getFormat() or getEncoder() are called.

        Parameters:
        image - the image to handle In- and Output of
        useTransparent - if true, returned encoders will use fully transparent pixels
    • Method Detail

      • getImageAsByteArray

        public byte[] getImageAsByteArray()
                                   throws java.io.IOException,
                                          ImageWritingException

        Returns the image in its current state (Output-Image) as a byte Array.

        If the image was not yet processed, return == input

        Specified by:
        getImageAsByteArray in interface ImageStegIO
        Returns:
        the image in its current state as a byte array
        Throws:
        java.io.IOException - if there was an error during writing of BufferedImage to a byte array
        ImageWritingException - if the image was not written to a byte array for unknown reasons
      • getEncoder

        public BuffImgEncoder getEncoder​(long seed)
                                  throws UnsupportedImageTypeException,
                                         java.io.IOException,
                                         NoImageException

        Determines and returns the suitable encoder (and overlay) for the image according to its type.

        Processes the image if it was not processed already.

        Specified by:
        getEncoder in interface ImageStegIO
        Parameters:
        seed - to hand to the overlay
        Returns:
        BuffImgEncoder with set PixelCoordinateOverlay, chosen accordingly to the images type
        Throws:
        UnsupportedImageTypeException - if the images type is not supported by any known encoder / overlay
        java.io.IOException - if there was an error during reading of input
        NoImageException - if no image could be read from input
      • getOverlay

        protected PixelCoordinateOverlay getOverlay​(java.awt.image.BufferedImage bufferedImage,
                                                    long seed)
                                             throws UnsupportedImageTypeException
        Returns an overlay according to the global variable useTransparent
        Parameters:
        bufferedImage - BufferedImage to hand to overlay
        seed - Seed to hand to overlay
        Returns:
        ShuffleOverlay or RemoveTransparentShuffleOverlay
        Throws:
        UnsupportedImageTypeException - if the image type is not supported by the overlay