Пример #1
0
        public static string GetString(Container container)
        {
            StringBuilder result = new StringBuilder();
            List<byte> bytes = new List<byte>();
            byte[] containerBytes = container.GetData().ToArray();
            for (int i = 0; i < 3; i++)
            {
                PrintLine(result, containerBytes[i]);
            }

            foreach (Frame frame in container.Frames)
            {
                result.AppendLine(string.Empty);
                result.Append(GetString(frame));

                foreach (Chunk chunk in frame.Chunks)
                {
                    result.AppendLine(string.Empty);
                    byte[] output = chunk.GetData().ToArray();
                    foreach (byte b in output)
                    {
                        PrintLine(result, b);
                    }
                }
            }

            return result.ToString();
        }
Пример #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);
        }