private void RenderPixels(Entity.Game game, ICollection <RenderPixelModel> pixels, string imageName, bool skipIfExists = false) { var start = DateTime.UtcNow; var outputDirectory = Path.Combine(_outputPath, $"{game.Id}"); if (!Directory.Exists(outputDirectory)) { Directory.CreateDirectory(outputDirectory); } var filename = Path.Combine(outputDirectory, $"{imageName}.png"); var filenameThumb = Path.Combine(outputDirectory, $"{imageName}-thumb.png"); if (skipIfExists && File.Exists(filename)) { return; } Log.Message(LogLevel.Info, $"[RenderPixels] - Rendering Pixels, GameId: {game.Id}, Pixels: {pixels.Count}, Image: {imageName}.png"); using (var bitmap = new Bitmap(game.Width, game.Height)) { foreach (var pixel in pixels) { bitmap.SetPixel(pixel.X, pixel.Y, ColorTranslator.FromHtml(pixel.Color)); } bitmap.Save(filename, ImageFormat.Png); using (var bitmapthumb = new Bitmap(bitmap, game.Width / 2, game.Height / 2)) { bitmapthumb.Save(filenameThumb, ImageFormat.Png); } } Log.Message(LogLevel.Info, $"[RenderPixels] - Rendering pixels complete, Elapsed: {DateTime.UtcNow - start}ms"); }
public void Sale(Entity.Game game) { throw new NotImplementedException(); }