Ejemplo n.º 1
0
        /// <summary>
        /// Modify least significant bit of a large photo to put smaller photos in it
        /// </summary>
        /// <param name="source">Source photo to put another image in it</param>
        /// <param name="row">Start row of large photo for starting modification</param>
        /// <param name="column">Start column of large photo for starting modification</param>
        /// <param name="pixelColor">The color of pixel in secret photo</param>
        private static void ModifyPhotoUsingLSB(this Image <Rgb, byte> source, int row, int column, Rgb pixelColor)
        {
            var(rBinary, gBinary, bBinary) = pixelColor.BinaryRepresentationOfColor();
            int newR, newG, newB; bool isZero;

            for (int k = 0; k < 8; k++)
            {
                var  targetPixel = source[row, column];
                byte r           = (byte)targetPixel.Red;
                byte g           = (byte)targetPixel.Green;
                byte b           = (byte)targetPixel.Blue;

                // Red
                isZero = rBinary[7 - k] == '0';
                newR   = (isZero) ? r.ResetLSB() : r.SetLSB();

                // Green
                isZero = gBinary[7 - k] == '0';
                newG   = (isZero) ? g.ResetLSB() : g.SetLSB();

                // Blue
                isZero = bBinary[7 - k] == '0';
                newB   = (isZero) ? b.ResetLSB() : b.SetLSB();

                source[row, column] = new Rgb(newR, newG, newB);

                IncrementPhotoIndex(ref row, ref column, 1000);
            }
        }