public ImagePicker(InputArchive archive, bool allowDuplicate, int total) { _archive = archive; _allowDuplicate = allowDuplicate; _imageInfos = new LinkedList <ImageInfo>(archive.GetImageInfos().ImageInfos); if (_archive.GetImageInfos().Count < total) { //Get the minimum amount of duplications to surpass the total var dupAmount = Math.Ceiling(total / (double)_archive.GetImageInfos().Count); Console.WriteLine($"Not enough images, duplicating the list {dupAmount} times."); DuplicateImages((int)dupAmount); } }
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); }