diff --git a/ASP.NET/Controllers/ImageController.cs b/ASP.NET/Controllers/ImageController.cs index ffbd67e..8a4aa15 100644 --- a/ASP.NET/Controllers/ImageController.cs +++ b/ASP.NET/Controllers/ImageController.cs @@ -34,25 +34,13 @@ namespace TCC.Controllers [HttpGet("load-image")] public async Task GetSimpleImage() { - var result = ImageService.GetSimpleImage(); - - var imageStream = new MemoryStream(); - result.Write(imageStream); - imageStream.Position = 0; - - return File(imageStream, "image/png"); + return File(ImageService.GetSimpleImage(), "image/png"); } [HttpGet("load-big-image")] public async Task GetBigImage() { - var result = ImageService.GetBigImage(); - - var imageStream = new MemoryStream(); - result.Write(imageStream); - imageStream.Position = 0; - - return File(imageStream, "image/png"); + return File(ImageService.GetBigImage(), "image/png"); } [HttpPost("save-big-image")] diff --git a/ASP.NET/ImageHelper.cs b/ASP.NET/ImageHelper.cs index 78aece5..650a6a9 100644 --- a/ASP.NET/ImageHelper.cs +++ b/ASP.NET/ImageHelper.cs @@ -4,13 +4,13 @@ namespace tcc_app { public static class ImageHelper { - public static MagickImage SimpleImage; - public static MagickImage BigImage; + public static byte[] SimpleImage; + public static byte[] BigImage; static ImageHelper() { - SimpleImage = new MagickImage("simpleimage.png"); - BigImage = new MagickImage("bigimage.png"); + SimpleImage = File.ReadAllBytes("static/simpleimage.png"); + BigImage = File.ReadAllBytes("static/bigimage.png"); } } } diff --git a/ASP.NET/Program.cs b/ASP.NET/Program.cs index 9f17c17..fdbd501 100644 --- a/ASP.NET/Program.cs +++ b/ASP.NET/Program.cs @@ -19,7 +19,6 @@ namespace TCC options.Limits.MaxRequestBodySize = int.MaxValue; // if don't set default value is: 30 MB }); - var app = builder.Build(); app.UseStaticFiles(new StaticFileOptions diff --git a/ASP.NET/Services/ImageService.cs b/ASP.NET/Services/ImageService.cs index fbe3d02..4f43e52 100644 --- a/ASP.NET/Services/ImageService.cs +++ b/ASP.NET/Services/ImageService.cs @@ -62,12 +62,12 @@ namespace TCC.Services file.Close(); } - public MagickImage GetSimpleImage() + public byte[] GetSimpleImage() { return ImageHelper.SimpleImage; } - public MagickImage GetBigImage() + public byte[] GetBigImage() { return ImageHelper.BigImage; }