11.07.2015 Views

Java Art Chapter 6. Steganography

Java Art Chapter 6. Steganography

Java Art Chapter 6. Steganography

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Java</strong> Prog. Techniques for Games. <strong>Java</strong> <strong>Art</strong> <strong>Chapter</strong> <strong>6.</strong> Stego Draft #1 (7th June 09)return buffer.getData();} // end of accessBytes()The code in accessBytes() can be understood by considering the data structures thatmake up a BufferedImage object, as shown in Figure 5.Figure 5. A BufferedImage Object.The Raster class manages the image data, employing the DataBuffer class to hold thepixel data. The SampleModel class interprets the buffer data as pixels, and theColorModel class provides a color interpretation for those pixels. accessBytes()accesses the raster using WritableRaster, which is the Raster subtype employed byBufferedImage so its pixel data can be modified.2.2. Combining the Text and the ImageHaving obtained a byte array for the stego (by calling buildStego()), and a byte arrayfor the image data (by calling accessBytes()), the two arrays are combined as shownin Figure 3. singleHide() does some checking first, before calling hideStego() to dothe necessary bit manipulation.private static boolean singleHide(byte[] imBytes, byte[] stego){int imLen = imBytes.length;System.out.println("Byte length of image: " + imLen);int totalLen = stego.length;System.out.println("Total byte length of message: " + totalLen);// check that the stego will fit into the image/* multiply stego length by number of image bytesrequired to store one stego byte */if ((totalLen*DATA_SIZE) > imLen) {System.out.println("Image not big enough for message");return false;}hideStego(imBytes, stego, 0); // hide at start of imagereturn true;} // end of singleHide()7 Andrew Davison © 2009

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!