public async Task <string> SerializeMarshallAsync <T>(T t)
        {
            string result = null;

            using (global::System.IO.MemoryStream ms = new global::System.IO.MemoryStream())
            {
                global::System.Runtime.Serialization.DataContractSerializer serializer = null;
                serializer = new global::System.Runtime.Serialization.DataContractSerializer(typeof(T));

                serializer.WriteObject(ms, t);

                ms.Seek(0, global::System.IO.SeekOrigin.Begin);

                using (global::System.IO.StreamReader sr = new global::System.IO.StreamReader(ms))
                {
                    result = await sr.ReadToEndAsync();
                }
            }

            return(result);
        }
        /// <summary>
        /// Returns a surface with the specified image rendered to it as characters.
        /// </summary>
        /// <param name="image">The image to render.</param>
        /// <returns>The surface.</returns>
        public TextSurface GetSurface(Texture2D image)
        {
            editor.Clear();

#if SFML
            using (var imageData = image.CopyToImage())
            {
                using (var memStream = new global::System.IO.MemoryStream())
                {
                    var binForm = new global::System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    memStream.Write(imageData.Pixels, 0, imageData.Pixels.Length);
                    memStream.Seek(0, global::System.IO.SeekOrigin.Begin);
                    pixels = (Color[])binForm.Deserialize(memStream);
                }
            }
#elif MONOGAME
            image.GetData <Color>(pixels);
#endif

            System.Threading.Tasks.Parallel.For(0, surface.Width * surface.Height, (i) =>
                                                //for (int i = 0; i < surface.Width * surface.Height; i++)
            {
                int allR = 0;
                int allG = 0;
                int allB = 0;

                int min = i * fontPixels;
                int max = min + fontPixels;

                for (int pixel = min; pixel < max; pixel++)
                {
                    Color color = pixels[indexes[pixel]];

                    allR += color.R;
                    allG += color.G;
                    allB += color.B;
                }

                // print our character
                byte sr = (byte)(allR / fontPixels);
                byte sg = (byte)(allG / fontPixels);
                byte sb = (byte)(allB / fontPixels);

                var newColor = new Color(sr, sg, sb);
                float sbri   = newColor.GetBrightness() * 255;


                Point surfacePoint = surface.GetPointFromIndex(i);
                if (UseBlockMode)
                {
                    if (sbri > 204)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 219, newColor); //█
                    }
                    else if (sbri > 152)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 178, newColor); //▓
                    }
                    else if (sbri > 100)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 177, newColor); //▒
                    }
                    else if (sbri > 48)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 176, newColor); //░
                    }
                    else
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 0, Color.Black);
                    }
                }
                else
                {
                    if (sbri > 230)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'#', newColor);
                    }
                    else if (sbri > 207)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'&', newColor);
                    }
                    else if (sbri > 184)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'$', newColor);
                    }
                    else if (sbri > 161)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'X', newColor);
                    }
                    else if (sbri > 138)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'x', newColor);
                    }
                    else if (sbri > 115)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'=', newColor);
                    }
                    else if (sbri > 92)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'+', newColor);
                    }
                    else if (sbri > 69)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)';', newColor);
                    }
                    else if (sbri > 46)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)':', newColor);
                    }
                    else if (sbri > 23)
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'.', newColor);
                    }
                    else
                    {
                        editor.SetGlyph(surfacePoint.X, surfacePoint.Y, 0, Color.Black);
                    }
                }
            }
                                                );

            return(surface);
        }