Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan authored Mar 23, 2024
1 parent 27c94f1 commit 8c9eabf
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions nQuant.Console/ConsoleApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,31 +221,30 @@ private static void OutputImages(string sourceDir)

var alg = new APNsgaIII<PnnLABGAQuantizer>(new PnnLABGAQuantizer(new PnnLABQuantizer(), bitmaps, maxColors));
alg.Run(999, -Double.Epsilon);
using (var pGAq = alg.Result) {
System.Console.WriteLine("\n" + pGAq.Result);
var destPath = string.Empty;
var imgs = pGAq.QuantizeImage(dither);
if (maxColors > 256)
{
for (int i = 0; i < imgs.Count; ++i)
{
var fname = Path.GetFileNameWithoutExtension(paths[i]);
destPath = Path.Combine(targetPath, fname) + " - PNNLAB+quant" + maxColors + ".png";
imgs[i].Save(destPath, ImageFormat.Png);
System.Console.WriteLine("Converted image: " + Path.GetFullPath(destPath));
}
}
else
{
var fname = Path.GetFileNameWithoutExtension(paths[0]);
destPath = Path.Combine(targetPath, fname) + " - PNNLAB+quant" + maxColors + ".gif";
var gifWriter = new GifWriter(destPath, pGAq.HasAlpha, imgs.Count, 850);
gifWriter.AddImages(imgs);
}
using var pGAq = alg.Result;
System.Console.WriteLine("\n" + pGAq.Result);
var destPath = string.Empty;
var imgs = pGAq.QuantizeImage(dither);
if (maxColors > 256)
{
for (int i = 0; i < imgs.Count; ++i)
{
var fname = Path.GetFileNameWithoutExtension(paths[i]);
destPath = Path.Combine(targetPath, fname) + " - PNNLAB+quant" + maxColors + ".png";
imgs[i].Save(destPath, ImageFormat.Png);
System.Console.WriteLine("Converted image: " + Path.GetFullPath(destPath));
}
}
else
{
var fname = Path.GetFileNameWithoutExtension(paths[0]);
destPath = Path.Combine(targetPath, fname) + " - PNNLAB+quant" + maxColors + ".gif";
var gifWriter = new GifWriter(destPath, 850);
gifWriter.AddImages(imgs);
}

System.Console.WriteLine("Converted image: " + Path.GetFullPath(destPath));
}
}
System.Console.WriteLine("Converted image: " + Path.GetFullPath(destPath));
}
catch (Exception q)
{
System.Console.WriteLine(q.StackTrace);
Expand Down

0 comments on commit 8c9eabf

Please sign in to comment.