From d778911c4f553ed4f99876fc247c2306d073bf59 Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Sat, 29 Oct 2022 16:26:20 +0400 Subject: Minor refactoring. --- NesTiler/ColorFinder.cs | 2 +- NesTiler/Palette.cs | 4 ++-- NesTiler/Program.cs | 2 +- NesTiler/Tile.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NesTiler/ColorFinder.cs b/NesTiler/ColorFinder.cs index 748f844..257e9b1 100644 --- a/NesTiler/ColorFinder.cs +++ b/NesTiler/ColorFinder.cs @@ -11,7 +11,7 @@ namespace com.clusterrr.Famicom.NesTiler { class ColorFinder { - static byte[] FORBIDDEN_COLORS = new byte[] { 0x0D, 0x0E, 0x0F, 0x1E, 0x1F, 0x2E, 0x2F, 0x3E, 0x3F }; + static byte[] FORBIDDEN_COLORS = { 0x0D, 0x0E, 0x0F, 0x1E, 0x1F, 0x2E, 0x2F, 0x3E, 0x3F }; public readonly Dictionary Colors; private readonly Dictionary cache = new(); diff --git a/NesTiler/Palette.cs b/NesTiler/Palette.cs index d6d1747..203a9de 100644 --- a/NesTiler/Palette.cs +++ b/NesTiler/Palette.cs @@ -59,7 +59,7 @@ namespace com.clusterrr.Famicom.NesTiler TileY = tileY, TileWidth = tileWidth, TileHeight = tileHeight, - Colors = Enumerable.Concat(new SKColor[] { bgColor }, colorsCandidates.Select(kv => kv.Key)).ToArray() + Colors = Enumerable.Concat(new[] { bgColor }, colorsCandidates.Select(kv => kv.Key)).ToArray() }; colors = colorsCandidates.Take(3).OrderBy(kv => kv.Key.ToArgb()).Select(kv => kv.Key).ToArray(); } @@ -92,7 +92,7 @@ namespace com.clusterrr.Famicom.NesTiler Color2 = bgColor }; if (deltaCache.ContainsKey(pair)) return deltaCache[pair]; - var ac = Enumerable.Concat(colors, new SKColor[] { bgColor }); + var ac = Enumerable.Concat(colors, new[] { bgColor }); var result = ac.OrderBy(c => c.GetDelta(color)).First(); var r = (result, result.GetDelta(color)); deltaCache[pair] = r; diff --git a/NesTiler/Program.cs b/NesTiler/Program.cs index 90c729f..fb24e93 100644 --- a/NesTiler/Program.cs +++ b/NesTiler/Program.cs @@ -347,7 +347,7 @@ namespace com.clusterrr.Famicom.NesTiler var color = image.GetPixelColor((tilePalX * c.TilePalWidth) + x, cy); var similarColor = nesColors.FindSimilarColor(Enumerable.Concat( bestPalette, - new SKColor[] { bgColor } + new[] { bgColor } ), color); image.SetPixelColor( (tilePalX * c.TilePalWidth) + x, diff --git a/NesTiler/Tile.cs b/NesTiler/Tile.cs index 98739c0..123ecc9 100644 --- a/NesTiler/Tile.cs +++ b/NesTiler/Tile.cs @@ -34,7 +34,7 @@ namespace com.clusterrr.Famicom.NesTiler if ((Pixels[(y * Width) + x] & 2) != 0) // check bit 1 data[(y / 8 * 16) + (y % 8) + 8] |= (byte)(1 << bit); pixel++; - bit = (byte)((byte)(bit - 1) % 8); // decrease bit number, wrap around if need + bit = unchecked((byte)((byte)(bit - 1) % 8)); // decrease bit number, wrap around if need } } } -- cgit v1.2.3