public static ASCIIImage CreateASCIIImage(ExtendedImage image)
 {
     return(new ASCIIImage(image));
 }
Example #2
0
        private static void OutputChars(int imageHeight, int imageWidth, int stepY, int stepX, ExtendedImage image, char[] charsByDarkness, int min, int max)
        {
            for (int y = 0; y < imageHeight - stepY; y += stepY)
            {
                for (int x = 0; x < imageWidth - stepX; x += stepX)
                {
                    int sum = GetSum(x, y, stepX, stepY, image);
                    Console.Write(charsByDarkness[(sum - min) * charsByDarkness.Length / (max - min + 1)]);
                }

                Console.WriteLine();
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            var image           = ExtendedImage.CreateImage("pair_hiking.png");
            var charsByDarkness = new char[] { '#', '@', 'X', 'L', 'I', ':', '.', ' ' };
            int max             = 0;
            int min             = 255 * 3;
            int stepY           = image.GetHeight() / 45;
            int stepX           = image.GetWidth() / 150;
            int min2;
            int max2;

            GoThroughImageHeightAndWidth(image, stepX, stepY, min, max, out min2, out max2);

            GoThroughImageHeightAndWidth(image, stepX, stepY, min2, max2, charsByDarkness);


            // This is the original code to make shorter and more readable
            //
            //for (int y = 0; y < image.GetHeight(); y += stepY)
            //{
            //    for (int x = 0; x < image.GetWidth(); x += stepX)
            //    {
            //        int sum = 0;
            //        for (int avgy = 0; avgy < stepY; avgy++)
            //        {
            //            for (int avgx = 0; avgx < stepX; avgx++)
            //            {
            //                sum = sum + (image.GetRed(new Point(x, y)) + image.GetBlue(new Point(x, y)) + image.GetGreen(new Point(x, y)));
            //            }
            //        }
            //        sum = sum / stepY / stepX;
            //        if (max < sum)
            //        {
            //            max = sum;
            //        }
            //        if (min > sum)
            //        {
            //            min = sum;
            //        }
            //    }
            //}


            //for (int y = 0; y < image.GetHeight() - stepY; y += stepY)
            //{
            //    for (int x = 0; x < image.GetWidth() - stepX; x += stepX)
            //    {
            //        int sum = 0;
            //        for (int avgy = 0; avgy < stepY; avgy++)
            //        {
            //            for (int avgx = 0; avgx < stepX; avgx++)
            //            {
            //                sum = sum + (image.GetRed(new Point(x, y)) + image.GetBlue(new Point(x, y)) + image.GetGreen(new Point(x, y)));
            //            }
            //        }

            //        sum = sum / stepY / stepX;
            //        Console.Write(charsByDarkness[(sum - min2) * charsByDarkness.Length / (max2 - min2 + 1)]);
            //    }

            //    Console.WriteLine();
            //}

            Console.ReadLine();
        }