Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/NesTiler.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-28 19:01:12 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-28 19:01:12 +0300
commite657a3b476b096250a473b3b684abf328b7f0cbe (patch)
tree4bf6a76e4de6e90f687cf500b330bbfb8ac0a16e
parent7ede863fcfa68e44fceb766c3191e5bd98f2cdc9 (diff)
Better error messages.
-rw-r--r--NesTiler/Palette.cs7
-rw-r--r--NesTiler/Program.cs10
2 files changed, 11 insertions, 6 deletions
diff --git a/NesTiler/Palette.cs b/NesTiler/Palette.cs
index 921f9af..d6d1747 100644
--- a/NesTiler/Palette.cs
+++ b/NesTiler/Palette.cs
@@ -14,11 +14,11 @@ namespace com.clusterrr.Famicom.NesTiler
public struct LossyInfo
{
public int ImageNum { get; init; }
- public int ColorCount { get; init; }
public int TileX { get; init; }
public int TileY { get; init; }
public int TileWidth { get; init; }
public int TileHeight { get; init; }
+ public SKColor[] Colors { get; init; }
}
private SKColor[] colors;
@@ -51,16 +51,15 @@ namespace com.clusterrr.Famicom.NesTiler
}
}
- // TODO: one more lossy level?
var colorsCandidates = colorCounter.OrderByDescending(kv => kv.Value);
if (colorsCandidates.Count() > 3) ColorLossy = new()
{
ImageNum = imageNum,
- ColorCount = colorsCandidates.Count(),
TileX = tileX,
TileY = tileY,
TileWidth = tileWidth,
- TileHeight = tileHeight
+ TileHeight = tileHeight,
+ Colors = Enumerable.Concat(new SKColor[] { bgColor }, colorsCandidates.Select(kv => kv.Key)).ToArray()
};
colors = colorsCandidates.Take(3).OrderBy(kv => kv.Key.ToArgb()).Select(kv => kv.Key).ToArray();
}
diff --git a/NesTiler/Program.cs b/NesTiler/Program.cs
index 990f0dd..c23d5ab 100644
--- a/NesTiler/Program.cs
+++ b/NesTiler/Program.cs
@@ -174,7 +174,10 @@ namespace com.clusterrr.Famicom.NesTiler
c.TilePalHeight,
c.BgColor.Value);
if ((c.LossyLevel <= 1) && (lossyInfo != null))
- throw new InvalidDataException($"Image #{lossyInfo?.ImageNum}, tile at X={lossyInfo?.TileX} Y={lossyInfo?.TileY} has {lossyInfo?.ColorCount + 1} colors while only 4 is possible.");
+ throw new InvalidDataException($"Image #{lossyInfo?.ImageNum}, " +
+ $"tile at ({lossyInfo?.TileX},{lossyInfo?.TileY})-" +
+ $"({lossyInfo?.TileX + lossyInfo?.TileWidth},{lossyInfo?.TileY + lossyInfo?.TileHeight}) has {lossyInfo?.Colors?.Length} " +
+ $"colors ({string.Join(", ", lossyInfo?.Colors?.Select(c => c.ToHtml())!)}) while only 4 possible.");
}
else
{
@@ -237,7 +240,10 @@ namespace com.clusterrr.Famicom.NesTiler
var kvLossy = calcResults.OrderBy(kv => kv.Value.Palettes.Length).First();
lossyInfo = kvLossy.Value.LossyInfo;
if (c.LossyLevel <= 1)
- throw new InvalidDataException($"Image #{lossyInfo?.ImageNum}, tile at X={lossyInfo?.TileX} Y={lossyInfo?.TileY} has {lossyInfo?.ColorCount + 1} colors while only 4 is possible.");
+ throw new InvalidDataException($"Image #{lossyInfo?.ImageNum}, " +
+ $"tile at ({lossyInfo?.TileX},{lossyInfo?.TileY})-" +
+ $"({lossyInfo?.TileX + lossyInfo?.TileWidth},{lossyInfo?.TileY + lossyInfo?.TileHeight}) has {lossyInfo?.Colors?.Length} " +
+ $"colors ({string.Join(", ", lossyInfo?.Colors?.Select(c => c.ToHtml())!)}) while only 4 possible.");
(bgColor, calculatedPalettes) = (kvLossy.Key, kvLossy.Value.Palettes);
}
Trace.WriteLine(bgColor.ToHtml());