Package steganography.util
Class ImageStegIOJava
- java.lang.Object
-
- steganography.util.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
-
-
-
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 ofuseTransparent
- 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 interfaceImageStegIO
- 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 arrayImageWritingException
- if the image was not written to a byte array for unknown reasons
-
getFormat
public java.lang.String getFormat() throws UnsupportedImageTypeException, java.io.IOException, NoImageException
Returns the images format.
Processes the image if necessary.
- Specified by:
getFormat
in interfaceImageStegIO
- Returns:
- the images format (png, bmp, ...) as a String
- Throws:
UnsupportedImageTypeException
- if the image type read from input is not supportedjava.io.IOException
- if there was an error during reading of inputNoImageException
- if no image could be read from input
-
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 interfaceImageStegIO
- 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 / overlayjava.io.IOException
- if there was an error during reading of inputNoImageException
- 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 overlayseed
- Seed to hand to overlay- Returns:
- ShuffleOverlay or RemoveTransparentShuffleOverlay
- Throws:
UnsupportedImageTypeException
- if the image type is not supported by the overlay
-
-