public void Render(string outputDirectory, string outputFilename) { _log.Info("Loading trajectories..."); _hitPlotRed.LoadTrajectories(Path.Combine(_inputInputDirectory, _inputFilenameRed)); _hitPlotGreen.LoadTrajectories(Path.Combine(_inputInputDirectory, _inputFilenameGreen)); _hitPlotBlue.LoadTrajectories(Path.Combine(_inputInputDirectory, _inputFilenameBlue)); _log.Info("Done loading; finding maximums..."); var maxRed = _hitPlotRed.Max(); var maxGreen = _hitPlotGreen.Max(); var maxBlue = _hitPlotBlue.Max(); _log.DebugFormat("Found maximum red: {0:N0}", maxRed); _log.DebugFormat("Found maximum green: {0:N0}", maxGreen); _log.DebugFormat("Found maximum blue: {0:N0}", maxBlue); _log.Info("Starting to render"); var outputImg = new Bitmap(_resolution.Width, _resolution.Height); var processedPixels = _resolution .GetAllPoints() .AsParallel() .WithDegreeOfParallelism(GlobalArguments.DegreesOfParallelism) .Select(p => ComputeColor(p, maxRed, maxGreen, maxBlue)) .AsEnumerable(); foreach (var result in processedPixels) { outputImg.SetPixel(result.Item1.X, result.Item1.Y, result.Item2); } _log.Info("Finished rendering"); _log.Debug("Saving image"); outputImg.Save(Path.Combine(outputDirectory, String.Format("{0}.png", outputFilename))); _log.Debug("Done saving image"); }
public void Render(string outputDirectory, string outputFilename, ColorRamp colorRamp) { _log.InfoFormat("Creating image ({0:N0}x{1:N0})", _resolution.Width, _resolution.Height); _log.Info("Loading trajectory..."); _hitPlot.LoadTrajectories(Path.Combine(_inputInputDirectory, _inputFilename)); _log.Info("Done loading; finding maximum..."); var max = _hitPlot.Max(); _log.DebugFormat("Found maximum: {0:N0}", max); _log.Info("Starting to render"); var outputImg = new Bitmap(_resolution.Width, _resolution.Height); var processedPixels = _resolution .GetAllPoints() .AsParallel() .WithDegreeOfParallelism(GlobalArguments.DegreesOfParallelism) .Select(p => ComputeColor(p, max, colorRamp)) .AsEnumerable(); foreach (var result in processedPixels) { outputImg.SetPixel(result.Item1.X, result.Item1.Y, result.Item2); } _log.Info("Finished rendering"); _log.Debug("Saving image"); outputImg.Save(Path.Combine(outputDirectory, String.Format("{0}.png", outputFilename))); _log.Debug("Done saving image"); }