From 022a559bc74fe81b561939f21d48682012f3073e Mon Sep 17 00:00:00 2001 From: goremykin Date: Mon, 21 Apr 2025 13:42:16 +0200 Subject: [PATCH] Remove System.Drawing.Common dependency --- API.Tests/Services/ImageServiceTests.cs | 4 ++-- API/API.csproj | 1 - API/Services/ImageService.cs | 6 ++---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/API.Tests/Services/ImageServiceTests.cs b/API.Tests/Services/ImageServiceTests.cs index ff1917a0a..f2c87e1ad 100644 --- a/API.Tests/Services/ImageServiceTests.cs +++ b/API.Tests/Services/ImageServiceTests.cs @@ -161,9 +161,9 @@ public class ImageServiceTests private static void GenerateColorImage(string hexColor, string outputPath) { - var color = ImageService.HexToRgb(hexColor); + var (r, g, b) = ImageService.HexToRgb(hexColor); using var blackImage = Image.Black(200, 100); - using var colorImage = blackImage.NewFromImage(color.R, color.G, color.B); + using var colorImage = blackImage.NewFromImage(r, g, b); colorImage.WriteToFile(outputPath); } diff --git a/API/API.csproj b/API/API.csproj index 52c390f4e..b518a72c0 100644 --- a/API/API.csproj +++ b/API/API.csproj @@ -100,7 +100,6 @@ - diff --git a/API/Services/ImageService.cs b/API/Services/ImageService.cs index 0255b785d..544efa4ce 100644 --- a/API/Services/ImageService.cs +++ b/API/Services/ImageService.cs @@ -10,11 +10,9 @@ using API.Entities.Interfaces; using API.Extensions; using Microsoft.Extensions.Logging; using NetVips; -using SixLabors.ImageSharp; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Quantization; -using Color = System.Drawing.Color; using Image = NetVips.Image; namespace API.Services; @@ -750,7 +748,7 @@ public class ImageService : IImageService } - public static Color HexToRgb(string? hex) + public static (int R, int G, int B) HexToRgb(string? hex) { if (string.IsNullOrEmpty(hex)) throw new ArgumentException("Hex cannot be null"); @@ -774,7 +772,7 @@ public class ImageService : IImageService var g = Convert.ToInt32(hex.Substring(2, 2), 16); var b = Convert.ToInt32(hex.Substring(4, 2), 16); - return Color.FromArgb(r, g, b); + return (r, g, b); }