private static bool loopOverColors(ref Bitmap image, int height, int width, ref int binaryMessageIndex, ref string binaryMessage, PixelDataFunction pixelDataFunction) { bool finishedProcess = false; // Construct array of binary RGB values Color pixel = image.GetPixel(width, height); string[] binaryPixel = getBinaryPixel(pixel); // Loop over RGB colors individualy for (int i = 0, amountOfColors = binaryPixel.Length; i < amountOfColors; i++) { finishedProcess = pixelDataFunction(ref image, ref binaryMessageIndex, ref binaryMessage, ref binaryPixel[i]); if (finishedProcess) { break; } } // Convert colors to pixel Color mutatedPixel = Color.FromArgb(getColorFromBinaryString(binaryPixel[0]), getColorFromBinaryString(binaryPixel[1]), getColorFromBinaryString(binaryPixel[2])); image.SetPixel(width, height, mutatedPixel); return finishedProcess; }
private static void loopOverAllPixels(ref Bitmap image, ref int binaryMessageIndex, ref string binaryMessage, PixelDataFunction pixelDataFunction) { // Loop over vertical pixels for (int h = 0, imageHeight = image.Height; h < imageHeight; h++) { if (loopOverHorizontalPixels(ref image, h, ref binaryMessageIndex, ref binaryMessage, pixelDataFunction)) { break; } } }
private static bool loopOverHorizontalPixels(ref Bitmap image, int height, ref int binaryMessageIndex, ref string binaryMessage, PixelDataFunction pixelDataFunction) { bool finishedProcess = false; // Loop over horizontal pixels for (int w = 0, imageWidth = image.Width; w < imageWidth; w++) { finishedProcess = loopOverColors(ref image, height, w, ref binaryMessageIndex, ref binaryMessage, pixelDataFunction); if (finishedProcess) { break; } } return finishedProcess; }