From 2085b7d89bec1a4d6c6561961f9a43bcefe94458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique=20Ivanchechen?= Date: Tue, 29 Aug 2023 16:20:40 -0300 Subject: [PATCH] =?UTF-8?q?mudan=C3=A7as?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ASP.NET/Controllers/ImageController.cs | 16 ++-------------- ASP.NET/ImageHelper.cs | 8 ++++---- ASP.NET/Program.cs | 1 - ASP.NET/Services/ImageService.cs | 4 ++-- 4 files changed, 8 insertions(+), 21 deletions(-) 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; }