using Microsoft.AspNetCore.Mvc; using TCC.Services; namespace TCC.Controllers { [ApiController] [Route("image")] public class ImageController : ControllerBase { private ImageService ImageService { get; set; } public byte[] ImageData { get; set; } public ImageController(ImageService imageService) { this.ImageService = imageService; } [HttpPost("blur")] public async Task BlurImage([FromQuery] int radius) { MemoryStream mstream = new MemoryStream(); await HttpContext.Request.Body.CopyToAsync(mstream); mstream.Position = 0; var result = ImageService.BoxBlurImage(mstream, radius); var blurredImageStream = new MemoryStream(); result.Write(blurredImageStream); blurredImageStream.Position = 0; return File(blurredImageStream, "image/png"); } [HttpGet("load-small-image")] public async Task GetSimpleImage() { return File(ImageService.GetSimpleImage(), "image/png"); } [HttpGet("load-big-image")] public async Task GetBigImage() { return File(ImageService.GetBigImage(), "image/png"); } [HttpPost("save-big-image")] public async Task SaveBigImage() { MemoryStream mstream = new MemoryStream(); await HttpContext.Request.Body.CopyToAsync(mstream); mstream.Position = 0; return Ok(); } } }