/// <summary> /// Determines whether a pixel /// instance is a yellow-dot /// </summary> private static bool IsYellowDot(ImGearDIB igDIB, int x_position, int y_position) { const int redChannel = 0; const int greenChannel = 1; const int blueChannel = 2; int red, green, blue; ///////////////////////////////////////////////////////////////////////////////////////////////////////// // This remainder of this function will be left for contestants to implement // // Hint: // Gets a pixel from the ImGearDIB instance. // https://help.accusoft.com/ImageGear-Net/v24.11/Windows/HTML/webframe.html#topic3854.html // Sets variables red, green, and blue with their appropriate values from ImGearPixel instance. // https://help.accusoft.com/ImageGear-Net/v24.11/Windows/HTML/webframe.html#topic4189.html // // contestant implementation ------------------------------------------------------------------------------ ImGearPixel p = igDIB.GetPixelCopy(x_position, y_position); red = p[0]; green = p[1]; blue = p[2]; // end contestant implementation -------------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////////////////////////////// CMYKColor cmyk = new CMYKColor(red, green, blue); return(YellowThreshold(cmyk.yellow)); }
/// <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(); }