Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: SxzWriter <sxzfilepath>");
                return;
            }

            string filename = args[0];

            if (!File.Exists(filename))
            {
                Console.WriteLine("Failed to find file " + filename);
                return;
            }

            byte[] byteData = Helper.ReadBytesFromFile(filename);
            Console.WriteLine("Read in size is " + byteData.Length);

            Container container = new Container();
            container.SetData(byteData);

            Helper.DrawContainer(Helper.GetPrefix(filename) + ".png", container);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: SxzAppend <sxzfilepath1> <sxzfilepath2>");
                return;
            }

            string filename1 = args[0];

            if (!File.Exists(filename1))
            {
                Console.WriteLine("Failed to find file " + filename1);
                return;
            }

            byte[] byteData = Helper.ReadBytesFromFile(filename1);
            Console.WriteLine("Read in size for file1 is " + byteData.Length);

            Container container = new Container();
            container.SetData(byteData);

            SxzPoint dimensions = new SxzPoint();
            container.EnsureDimensions(dimensions);
            dimensions.X = (int)(dimensions.X / 2);
            dimensions.Y = (int)(dimensions.Y / 2);

            string filename2 = args[1];

            if (!File.Exists(filename2))
            {
                Console.WriteLine("Failed to find file " + filename2);
                return;
            }

            byteData = Helper.ReadBytesFromFile(filename2);
            Console.WriteLine("Read in size for file2 is " + byteData.Length);
            Container container2 = new Container();
            container2.SetData(byteData);
            SxzPoint dimensions2 = new SxzPoint();
            container2.EnsureDimensions(dimensions2);
            dimensions.X = dimensions.X - (int)(dimensions2.X / 2);
            dimensions.Y = dimensions.Y - (int)(dimensions2.Y / 2);

            foreach (Frame frame in container2.Frames)
            {
                foreach (Chunk chunk in frame.Chunks)
                {
                    if (chunk.Origin == null)
                    {
                        continue;
                    }

                    chunk.Origin.X = chunk.Origin.X + dimensions.X;
                    chunk.Origin.Y = chunk.Origin.Y + dimensions.Y;
                }
            }

            container.Frames.AddRange(container2.Frames);

            byte[] output = container.GetData();
            Console.WriteLine("Output byte total is " + output.Length);
            Helper.WriteBytesToFile("appendoutput.sxz", output);
            File.WriteAllText("appendoutput.sxz.txt", Print.GetString(container));

            Helper.DrawContainer("appendoutput.png", container);
        }
Exemplo n.º 3
0
        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);
        }