Пример #1
0
        private void Process(Image <Rgba32> img)
        {
            for (int y = 0; y < height; y += yscale)
            {
                for (int x = 0; x < width; x += xscale)
                {
                    int  gray   = ProcessChunk(img, x, y);
                    char symbol = gray == -1 ? ' ' : Ascii.Symbol(gray);

                    output.Append(symbol);
                }

                output.Append(Environment.NewLine);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            String filename;
            string scale;

            if (args.Length == 0)
            {
                Console.Write("Input File Name: ");
                filename = Console.ReadLine();
                Console.Write("Input scale: ");
                scale = Console.ReadLine();
            }
            else
            {
                filename = args[0];
                scale    = args.Length > 1 ? args[1] : DEFAULT_SCALE.ToString();
            }

            // make sure "scale" is alright
            int intscale = DEFAULT_SCALE;

            try
            {
                intscale = int.Parse(scale);
            }
            catch (FormatException)
            {
                Console.WriteLine($"Error: {scale} is not an integer.");
                return;
            }

            try
            {
                Ascii ascii = new Ascii(filename, intscale);
                ascii.Export();
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine($"Error: File {filename} does not exist.");
            }
        }