static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Usage: SxzReader <options> <imagefilepath>"); return; } SxzColor backgroundColor = null; bool parseBackground = true; int backgroundType = 0; bool mostCommonColor = false; //Maximum number of bytes per pixel allowed for filtering fat chunks //Ideally this would be about 1 byte/pixel as is with indexed png images approximately (pre-compressed) double bitsPerPixel = 2; double colorDistance = 32; for (int argIndex = 0; argIndex < args.Length - 1; argIndex++) { if (args[argIndex].Equals("-bg")) { argIndex++; string colorInput = args[argIndex]; if (colorInput.Equals("none")) { parseBackground = false; } else if (colorInput.Equals("mostcommon")) { //removes most common color mostCommonColor = true; } else { backgroundColor = SxzColor.Hex(colorInput); } } else if (args[argIndex].Equals("-backgroundtype")) { argIndex++; if (!int.TryParse(args[argIndex], out backgroundType)) { Console.WriteLine("Invalid background type " + args[argIndex]); return; } } else if (args[argIndex].Equals("-bpp")) { argIndex++; if (!double.TryParse(args[argIndex], out bitsPerPixel)) { Console.WriteLine("Invalid Bits Per Pixel argument " + args[argIndex]); return; } } else if (args[argIndex].Equals("-distance")) { argIndex++; if (!double.TryParse(args[argIndex], out colorDistance)) { Console.WriteLine("Invalid Color Distance argument " + args[argIndex]); return; } } } string filename = args[args.Length - 1]; if (!File.Exists(filename)) { Console.WriteLine("Failed to find file " + filename); return; } ParseImage parseImage = new ParseImage(); Container container = parseImage.Parse(filename, backgroundColor, mostCommonColor, parseBackground, (BackgroundType)backgroundType, bitsPerPixel, colorDistance); File.WriteAllText(Helper.GetPrefix(filename) + ".sxz.txt", Print.GetString(container)); byte[] output = container.GetData(); Console.WriteLine("Output byte total is " + output.Length); Helper.WriteBytesToFile(Helper.GetPrefix(filename) + ".sxz", output); Helper.WriteBytesToZipFile(Helper.GetPrefix(filename) + ".sxz.gz", output); byte[] byteData = Helper.ReadBytesFromFile(Helper.GetPrefix(filename) + ".sxz"); Container otherContainer = new Container(); otherContainer.SetData(byteData); Helper.DrawContainer(Helper.GetPrefix(filename) + ".2.png", otherContainer); }
static void Main(string[] args) { if (!TestFilters()) { return; } if (!TestBinary()) { return; } if (!TestBoolsToBytes()) { return; } foreach (string filename in Filenames) { ParseImage parseImage = new ParseImage(); Container container = parseImage.Parse(filename, new SxzColor(255, 255, 255), false, false, (BackgroundType)0, 2, 32); string outputFilename = Helper.GetPrefix(filename) + ".2.png"; Helper.DrawContainer(outputFilename, container); if (!CompareTwoPngs(filename, outputFilename)) { Console.WriteLine("Failed on " + filename); return; } } }