public async Task Pic(ProfilePictureModel model)
        {
            if (!ModelState.IsValid)
            {
                Response.StatusCode = 500;
                return;
            }

            var imageProcessing = new ProfileGenerator();

            var nameParse = model.Name.Split(' ');
            var firstName = nameParse[0];
            var lastName  = string.Empty;

            if (nameParse.Length > 1)
            {
                lastName = nameParse[nameParse.Length - 1];
            }

            var pic = imageProcessing.GenerateProfile(
                firstName: firstName,
                lastName: lastName,
                width: model.Width,
                height: model.Height,
                color: model.Color
                );

            // Temporary
            var buffer = pic.GetBuffer();

            Response.ContentType = "image/jpeg";
            await Response.Body.WriteAsync(buffer, 0, buffer.Length);

            pic.Close();
        }
示例#2
0
    public static string GenerateProfileFile(string gpxPath)
    {
        //calcolo la cartella che contiene le tracce
        string folder = Path.GetFileName(Path.GetDirectoryName(gpxPath));

        string profileFileRelPath  = PathFunctions.GetProfileUrl(folder);
        string profileFileFullPath = HttpContext.Current.Server.MapPath(profileFileRelPath);

        if (!File.Exists(profileFileFullPath))
        {
            ProfileGenerator gen = new ProfileGenerator();
            gen.GenerateProfile(Helper.GetGpxParser(gpxPath), profileFileFullPath);
        }
        return(profileFileRelPath);
    }