private void CreateMosaic(string outputPath)
        {
            var pixelSize = _archive.GetImageInfos().Size;

            var outputWidth  = _template.Width * pixelSize;
            var outputHeight = _template.Height * pixelSize;

            using var output = new MagickImage(new MagickColor("#FFFFFF"), outputWidth, outputHeight)
                  {
                      Format = MagickFormat.Png
                  };
            using var pixelCollection = _template.GetPixels();

            var pixelCountTotal = pixelCollection.Count();

            //Bar
            var bar = new ProgressBar(pixelCountTotal, "Assembling mosaic");

            foreach (var pixel in pixelCollection)
            {
                var outputX = pixel.X * pixelSize;
                var outputY = pixel.Y * pixelSize;

                using (var image = _archive.GetImage(_images[new Point(pixel.X, pixel.Y)]))
                {
                    output.Composite(image, outputX, outputY);
                }

                bar.Tick();
            }


            output.Write(outputPath);
        }
Exemple #2
0
 public MagickImage MostFittingImage(MagickColor color)
 {
     return(_archive.GetImage(MostFittingImageFilename(color)));
 }