Ejemplo n.º 1
0
        public IActionResult Result(Core.ParametersModel settingsModel)
        {
            ImageFileModel imageFileModel = new ImageFileModel();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var file = HttpContext.Request.Form.Files.First();

            using (Stream stream = file.OpenReadStream())
            {
                imageFileModel.ImageInput     = new byte[file.Length];
                imageFileModel.ImageInputType = file.ContentType;
                stream.Read(imageFileModel.ImageInput);
                renderService.RenderImage(imageFileModel.ImageInput, settingsModel);
                imageFileModel.ImageSVG    = Encoding.ASCII.GetBytes(renderService.GetSvg());
                imageFileModel.ImageResult = renderService.GetPng();
            }
            return(View(imageFileModel));
        }