/// <summary> /// Driver function for the /// decoding solution /// </summary> private static void Main() { // Initialize ImageGear. InitializeImageGear(); // load image ImGearPage igPage = LoadPageFromLocalFile(micInstancePath); // get image dib ImGearDIB igDIB = igPage.DIB; // get image dimensions int height = igDIB.Height; int width = igDIB.Width; // get table dimensions int totalRows = height / encodingWidth; int totalColumns = width / encodingWidth; // storage for image's row values Dictionary <int, int> rowSumDict = new Dictionary <int, int>(); // step through pixel space foreach (int x_position in MoreEnumerable.Sequence(patternOffset, width, encodingWidth)) { foreach (int y_position in MoreEnumerable.Sequence(patternOffset, height, encodingWidth)) { if (IsYellowDot(igDIB, x_position, y_position)) { // define table coordinates int columnValue = (x_position - patternOffset) / encodingWidth + 1; int rowValue = (y_position - patternOffset) / encodingWidth + 1; if (IsUpdateableCoordinate(rowValue, columnValue)) { UpdateValueDict(ref rowSumDict, rowValue, columnValue, totalColumns); } } } } // create answer strings for output string serialAnswer = StringifyAnswer(rowSumDict, serialRows); string yearAnswer = StringifyAnswer(rowSumDict, yearRows); string monthAnswer = StringifyAnswer(rowSumDict, monthRows); string dayAnswer = StringifyAnswer(rowSumDict, dayRows); string hourAnswer = StringifyAnswer(rowSumDict, hourRows); string minuteAnswer = StringifyAnswer(rowSumDict, minuteRows); Console.WriteLine(string.Format(answerString, serialAnswer, monthAnswer, dayAnswer, yearAnswer, hourAnswer, minuteAnswer)); Console.ReadKey(); }
/** * Program entry point. */ static void Main(string[] args) { InitImageGear(); using (Stream mergedStream = new FileStream(mergedImageFilepath, FileMode.Open)) using (Stream recoveredStream = new FileStream(recoveredImageFilepath, FileMode.Create)) { // load merged image ImGearPage mergedImage = ImGearFileFormats.LoadPage(mergedStream); // extract hidden image ImGearPage recoveredImage = ExtractHiddenImage(mergedImage); ImGearFileFormats.SavePage(recoveredImage, recoveredStream, ImGearSavingFormats.PNG); } }
//This function should return an ImGearPage that contains the extracted hidden image public static ImGearPage ExtractHiddenImage(ImGearPage mergedImage) { int bitNum = 1; int bitShift = mergedImage.DIB.BitsPerChannel - bitNum; int bitMask = 0xFF >> bitShift; int imageWidth = mergedImage.DIB.Width; int imageHeight = mergedImage.DIB.Height; // initialize blank ImGearRasterPage ImGearPage hidden = new ImGearRasterPage(imageWidth, imageHeight, new ImGearColorSpace(ImGearColorSpaceIDs.RGBA), new int[] { 8, 8, 8, 8 }, true); // For Each Pixel for (int x = 0; x < imageWidth; ++x) { for (int y = 0; y < imageHeight; ++y) { // Copy Pixel ImGearPixel s = mergedImage.DIB.GetPixelCopy(x, y); ImGearPixel p = new ImGearPixel(4, 8); //For Each Channel for (int c = 0; c < 3; ++c) { // Get Low bit bool bit = (s[c] & (1 << 0)) != 0; // Set to Either 1 or 0 Followed by 7 0s if (bit) { p[c] = 128; //10000000 } else { p[c] = 0; //0000000 } } // Keep Alpha Channel Intact p[3] = 255; // Set the Pixel hidden.DIB.UpdatePixelFrom(x, y, p); } } // Return Extracted Image return(hidden); }