src/jpm/dg/HidingActivity.java
/**
	 * Embed bytes within pixel data.
	 * 
	 * @param originalData
	 *            Clean data.
	 * @param messageBytes
	 *            Bytes to embed.
	 * @param isRandom
	 *            If true the data is distributed randomly throughout the image.
	 * @return
	 */
Embed bytes within pixel data.

@param originalData
Clean data.
@param messageBytes
Bytes to embed.
@param isRandom
If true the data is distributed randomly throughout the image.
@return
Embed bytes within pixel data . @param originalData Clean data . @param messageBytes Bytes to embed . @param isRandom If true the data is distributed randomly throughout the image . @return
private byte[] encodeData(int[] originalData, byte[] messageBytes,
			boolean isRandom) {
		int shiftIndex = 4;
		byte[] encodedPixelData = Util.convertArray(originalData);
		int messageIndex = 0;
		int resultIndex = 0;
		boolean msgEnded = false;
		Random rng = new Random(originalData[0]);
		Set<Integer> usedPixels = new HashSet<Integer>();
		usedPixels.add(0);
		int element = -1;
		while (!msgEnded && !encodingTask.isCancelled()) {
			byte tmp = 0;
			if (isRandom) {
				element = 0;
				while (usedPixels.contains(element)) {
					element = rng.nextInt(originalData.length);
				}
				usedPixels.add(element);
			} else {
				element++;
				float progress = (float) element;
				progress /= ((float) messageBytes.length * 1.33);
				progress *= 100;
				encodingTask.updateProgress((int) progress);
			}
			resultIndex = element * 3;
			for (int channelIndex = 0; channelIndex < CHANNELS; channelIndex++) {
				if (!msgEnded) {
					tmp = (byte) ((((originalData[element] >> BINARY_CHANNELS[channelIndex]) & 0xFF) & 0xFC) | ((messageBytes[messageIndex] >> SHIFT_VALUES[(shiftIndex++)
							% SHIFT_VALUES.length]) & 0x3));
					if (shiftIndex % SHIFT_VALUES.length == 0) {
						messageIndex++;
					}
					if (messageIndex == messageBytes.length) {
						msgEnded = true;
					}
				} else {
					tmp = (byte) ((((originalData[element] >> BINARY_CHANNELS[channelIndex]) & 0xFF)));
				}
				encodedPixelData[resultIndex++] = tmp;
			}
		}
		return encodedPixelData;
	}
private byte [ ] encodeData ( int [ ] originalData , byte [ ] messageBytes , boolean isRandom ) { int shiftIndex = 4 ; byte [ ] encodedPixelData = Util . convertArray ( originalData ) ; int messageIndex = 0 ; int resultIndex = 0 ; boolean msgEnded = false ; Random rng = new Random ( originalData [ 0 ] ) ; Set < Integer > usedPixels = new HashSet < Integer > ( ) ; usedPixels . add ( 0 ) ; int element = - 1 ; while ( ! msgEnded && ! encodingTask . isCancelled ( ) ) { byte tmp = 0 ; if ( isRandom ) { element = 0 ; while ( usedPixels . contains ( element ) ) { element = rng . nextInt ( originalData . length ) ; } usedPixels . add ( element ) ; } else { element ++ ; float progress = ( float ) element ; progress /= ( ( float ) messageBytes . length * 1.33 ) ; progress *= 100 ; encodingTask . updateProgress ( ( int ) progress ) ; } resultIndex = element * 3 ; for ( int channelIndex = 0 ; channelIndex < CHANNELS ; channelIndex ++ ) { if ( ! msgEnded ) { tmp = ( byte ) ( ( ( ( originalData [ element ] >> BINARY_CHANNELS [ channelIndex ] ) & 0xFF ) & 0xFC ) | ( ( messageBytes [ messageIndex ] >> SHIFT_VALUES [ ( shiftIndex ++ ) % SHIFT_VALUES . length ] ) & 0x3 ) ) ; if ( shiftIndex % SHIFT_VALUES . length == 0 ) { messageIndex ++ ; } if ( messageIndex == messageBytes . length ) { msgEnded = true ; } } else { tmp = ( byte ) ( ( ( ( originalData [ element ] >> BINARY_CHANNELS [ channelIndex ] ) & 0xFF ) ) ) ; } encodedPixelData [ resultIndex ++ ] = tmp ; } } return encodedPixelData ; }
Embed bytes within pixel data.
Embed bytes within pixel data .