/// <summary> /// Kreiärt ä Render-Graph fir jedä Input-Tip und bindet si as /// virtueuä DMD. /// </summary> private void SetupGraphs() { var renderers = new List <IDestination>(); if (_config.PinDmd1.Enabled) { var pinDmd1 = PinDmd1.GetInstance(); if (pinDmd1.IsAvailable) { renderers.Add(pinDmd1); Logger.Info("Added PinDMDv1 renderer."); } } if (_config.PinDmd2.Enabled) { var pinDmd2 = PinDmd2.GetInstance(); if (pinDmd2.IsAvailable) { renderers.Add(pinDmd2); Logger.Info("Added PinDMDv2 renderer."); } } if (_config.PinDmd3.Enabled) { var pinDmd3 = PinDmd3.GetInstance(_config.PinDmd3.Port); if (pinDmd3.IsAvailable) { renderers.Add(pinDmd3); Logger.Info("Added PinDMDv3 renderer."); } } if (_config.Pin2Dmd.Enabled) { var pin2Dmd = Pin2Dmd.GetInstance(); if (pin2Dmd.IsAvailable) { renderers.Add(pin2Dmd); Logger.Info("Added PIN2DMD renderer."); } } if (_config.VirtualDmd.Enabled) { renderers.Add(_dmd.Dmd); Logger.Info("Added VirtualDMD renderer."); } if (_config.Video.Enabled) { var rootPath = ""; if (_config.Video.Path.Length == 0 || !Path.IsPathRooted(_config.Video.Path)) { rootPath = AssemblyPath; } if (Directory.Exists(Path.Combine(rootPath, _config.Video.Path))) { renderers.Add(new VideoOutput(Path.Combine(rootPath, _config.Video.Path, _gameName + ".avi"))); Logger.Info("Added video renderer."); } else if (Directory.Exists(Path.GetDirectoryName(Path.Combine(rootPath, _config.Video.Path))) && _config.Video.Path.Length > 4 && _config.Video.Path.EndsWith(".avi")) { renderers.Add(new VideoOutput(Path.Combine(rootPath, _config.Video.Path))); Logger.Info("Added video renderer."); } else { Logger.Warn("Ignoring video renderer for non-existing path \"{0}\"", _config.Video.Path); } } if (_config.VpdbStream.Enabled) { renderers.Add(new VpdbStream { EndPoint = _config.VpdbStream.EndPoint }); } if (_config.BrowserStream.Enabled) { renderers.Add(new BrowserStream(_config.BrowserStream.Port)); } if (renderers.Count == 0) { Logger.Error("No renderers found, exiting."); return; } Logger.Info("Transformation options: Resize={0}, HFlip={1}, VFlip={2}", _config.Global.Resize, _config.Global.FlipHorizontally, _config.Global.FlipVertically); // 2-bit graph if (_colorize && _gray2Colorizer != null) { _graphs.Add(new RenderGraph { Name = "2-bit Colored VPM Graph", Source = _vpmGray2Source, Destinations = renderers, Converter = _gray2Colorizer, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); } else { _graphs.Add(new RenderGraph { Name = "2-bit VPM Graph", Source = _vpmGray2Source, Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); } // 4-bit graph if (_colorize && _gray4Colorizer != null) { _graphs.Add(new RenderGraph { Name = "4-bit Colored VPM Graph", Source = _vpmGray4Source, Destinations = renderers, Converter = _gray4Colorizer, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); } else { _graphs.Add(new RenderGraph { Name = "4-bit VPM Graph", Source = _vpmGray4Source, Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); } // rgb24 graph _graphs.Add(new RenderGraph { Name = "RGB24-bit VPM Graph", Source = _vpmRgb24Source, Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); if (_colorize && (_gray2Colorizer != null || _gray4Colorizer != null)) { Logger.Info("Just clearing palette, colorization is done by converter."); _graphs.ClearColor(); } else if (_colorize && _palette != null) { Logger.Info("Applying palette to render graphs."); _graphs.ClearColor(); _graphs.SetPalette(_palette); } else { Logger.Info("Applying default color to render graphs ({0}).", _color); _graphs.ClearPalette(); _graphs.SetColor(_color); } _graphs.Init().StartRendering(); }
protected override void CreateRenderGraphs(RenderGraphCollection graphs, HashSet <string> reportingTags) { // define renderers var renderers = GetRenderers(_config, reportingTags); // retrieve image var bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri("pack://application:,,,/dmdext;component/Test/TestImage.png"); bmp.EndInit(); // chain them up if (_config.VirtualAlphaNumericDisplay.Enabled) { var alphaNumericFrame = new AlphaNumericFrame(NumericalLayout.__2x20Alpha, new ushort[] { 0, 10767, 2167, 8719, 0, 2109, 8713, 6259, 56, 2157, 0, 4957, 0, 8719, 62, 8719, 121, 2157, 0, 0, 0, 0, 5120, 8704, 16640, 0, 0, 0, 0, 2112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }); _graph = new RenderGraph { Source = new VpmAlphaNumericSource(alphaNumericFrame), Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }; } else { ISource source; switch (_testOptions.FrameFormat) { case FrameFormat.Gray2: source = new ImageSourceGray2(bmp); break; case FrameFormat.Gray4: source = new ImageSourceGray4(bmp); break; case FrameFormat.ColoredGray2: source = new ImageSourceColoredGray2(bmp); break; case FrameFormat.ColoredGray4: source = new ImageSourceColoredGray4(bmp); break; default: source = new ImageSourceBitmap(bmp); break; } _graph = new RenderGraph { Source = source, Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }; } graphs.Add(_graph); reportingTags.Add("In:Test"); }
protected override void CreateRenderGraphs(RenderGraphCollection graphs, HashSet <string> reportingTags) { // create graph with renderers _graph = new RenderGraph { Destinations = GetRenderers(_config, reportingTags, _options.Position), Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically, IdleAfter = _options.IdleAfter, IdlePlay = _options.IdlePlay }; _graph.SetColor(_config.Global.DmdColor); // setup source and additional processors switch (_options.Source) { case SourceType.PinballFX2: { _graph.Source = new PinballFX2Grabber { FramesPerSecond = _options.FramesPerSecond }; reportingTags.Add("In:PinballFX2"); break; } case SourceType.PinballFX3: { if (_options.Fx3GrabScreen) { _graph.Source = new PinballFX3Grabber { FramesPerSecond = _options.FramesPerSecond }; reportingTags.Add("In:PinballFX3Legacy"); } else { _graph.Source = new PinballFX3MemoryGrabber { FramesPerSecond = _options.FramesPerSecond }; reportingTags.Add("In:PinballFX3"); } break; } case SourceType.PinballArcade: { _graph.Source = new TPAGrabber { FramesPerSecond = _options.FramesPerSecond }; reportingTags.Add("In:PinballArcade"); break; } case SourceType.ProPinball: { _graph.Source = new ProPinballSlave(_options.ProPinballArgs); reportingTags.Add("In:ProPinball"); break; } case SourceType.Screen: var grabber = new ScreenGrabber { FramesPerSecond = _options.FramesPerSecond, Left = _options.Position[0], Top = _options.Position[1], Width = _options.Position[2] - _options.Position[0], Height = _options.Position[3] - _options.Position[1], DestinationWidth = _options.ResizeTo[0], DestinationHeight = _options.ResizeTo[1] }; if (_options.GridSpacing > 0) { grabber.Processors.Add(new GridProcessor { Width = _options.ResizeTo[0], Height = _options.ResizeTo[1], Spacing = _options.GridSpacing }); } _graph.Source = grabber; reportingTags.Add("In:ScreenGrab"); break; case SourceType.FuturePinball: _graph.Source = new FutureDmdSink(_options.FramesPerSecond); reportingTags.Add("In:FutureDmdSink"); break; default: throw new ArgumentOutOfRangeException(); } graphs.Add(_graph); graphs.SetDimensions(new LibDmd.Input.Dimensions(_options.ResizeTo[0], _options.ResizeTo[1])); }
/// <summary> /// Kreiärt ä Render-Graph fir jedä Input-Tip und bindet si as /// virtueuä DMD. /// </summary> private void SetupGraphs() { _graphs.Dispose(); ReportingTags.Clear(); ReportingTags.Add(Process.GetCurrentProcess().ProcessName); #if PLATFORM_X86 ReportingTags.Add("x86"); #elif PLATFORM_X64 ReportingTags.Add("x64"); #endif ReportingTags.Add("In:DmdDevice"); ReportingTags.Add("Game:" + _gameName); var renderers = new List <IDestination>(); if (_config.PinDmd1.Enabled) { var pinDmd1 = PinDmd1.GetInstance(); if (pinDmd1.IsAvailable) { renderers.Add(pinDmd1); Logger.Info("Added PinDMDv1 renderer."); ReportingTags.Add("Out:PinDMDv1"); } } if (_config.PinDmd2.Enabled) { var pinDmd2 = PinDmd2.GetInstance(); if (pinDmd2.IsAvailable) { renderers.Add(pinDmd2); Logger.Info("Added PinDMDv2 renderer."); ReportingTags.Add("Out:PinDMDv2"); } } if (_config.PinDmd3.Enabled) { var pinDmd3 = PinDmd3.GetInstance(_config.PinDmd3.Port); if (pinDmd3.IsAvailable) { renderers.Add(pinDmd3); Logger.Info("Added PinDMDv3 renderer."); ReportingTags.Add("Out:PinDMDv3"); } } if (_config.Pin2Dmd.Enabled) { var pin2Dmd = Output.Pin2Dmd.Pin2Dmd.GetInstance(_config.Pin2Dmd.Delay); if (pin2Dmd.IsAvailable) { renderers.Add(pin2Dmd); if (_coloring != null) { pin2Dmd.PreloadPalettes(_coloring); } Logger.Info("Added PIN2DMD renderer."); ReportingTags.Add("Out:PIN2DMD"); } } if (_config.Pixelcade.Enabled) { var pixelcade = Pixelcade.GetInstance(_config.Pixelcade.Port, _config.Pixelcade.ColorMatrix); if (pixelcade.IsAvailable) { renderers.Add(pixelcade); Logger.Info("Added Pixelcade renderer."); ReportingTags.Add("Out:Pixelcade"); } } if (_config.VirtualDmd.Enabled) { renderers.Add(_virtualDmd.Dmd); Logger.Info("Added VirtualDMD renderer."); ReportingTags.Add("Out:VirtualDMD"); } if (_config.VirtualAlphaNumericDisplay.Enabled) { _alphaNumericDest = VirtualAlphanumericDestination.GetInstance(Dispatcher.CurrentDispatcher, _config.VirtualAlphaNumericDisplay.Style, _config); renderers.Add(_alphaNumericDest); Logger.Info("Added virtual alphanumeric renderer."); ReportingTags.Add("Out:VirtualAlphaNum"); } if (_config.Video.Enabled) { var rootPath = ""; if (_config.Video.Path.Length == 0 || !Path.IsPathRooted(_config.Video.Path)) { rootPath = AssemblyPath; } if (Directory.Exists(Path.Combine(rootPath, _config.Video.Path))) { renderers.Add(new VideoOutput(Path.Combine(rootPath, _config.Video.Path, _gameName + ".avi"))); Logger.Info("Added video renderer."); ReportingTags.Add("Out:Video"); } else if (Directory.Exists(Path.GetDirectoryName(Path.Combine(rootPath, _config.Video.Path))) && _config.Video.Path.Length > 4 && _config.Video.Path.EndsWith(".avi")) { renderers.Add(new VideoOutput(Path.Combine(rootPath, _config.Video.Path))); Logger.Info("Added video renderer."); ReportingTags.Add("Out:Video"); } else { Logger.Warn("Ignoring video renderer for non-existing path \"{0}\"", _config.Video.Path); } } if (_config.PinUp.Enabled) { try { var pinupOutput = new PinUpOutput(_gameName); if (pinupOutput.IsAvailable) { renderers.Add(pinupOutput); Logger.Info("Added PinUP renderer."); ReportingTags.Add("Out:PinUP"); } } catch (Exception e) { Logger.Warn("Error opening PinUP output: {0}", e.Message); } } if (_config.Gif.Enabled) { var rootPath = ""; var dirPath = Path.GetDirectoryName(_config.Gif.Path); if (string.IsNullOrEmpty(dirPath) || !Path.IsPathRooted(_config.Video.Path)) { rootPath = AssemblyPath; } var path = Path.Combine(rootPath, _config.Gif.Path); if (Directory.Exists(Path.GetDirectoryName(path))) { renderers.Add(new GifOutput(path)); Logger.Info("Added animated GIF renderer, saving to {0}", path); ReportingTags.Add("Out:GIF"); } else { Logger.Warn("Ignoring animated GIF renderer for non-existing path \"{0}\"", Path.GetDirectoryName(path)); } } if (_config.VpdbStream.Enabled) { renderers.Add(new VpdbStream { EndPoint = _config.VpdbStream.EndPoint }); Logger.Info("Added VPDB stream renderer."); ReportingTags.Add("Out:VpdbStream"); } if (_config.BrowserStream.Enabled) { renderers.Add(new BrowserStream(_config.BrowserStream.Port, _gameName)); Logger.Info("Added browser stream renderer."); ReportingTags.Add("Out:BrowserStream"); } if (_config.NetworkStream.Enabled) { renderers.Add(NetworkStream.GetInstance(_config.NetworkStream, _gameName)); Logger.Info("Added network stream renderer."); ReportingTags.Add("Out:NetworkStream"); } if (renderers.Count == 0) { Logger.Error("No renderers found, exiting."); return; } Logger.Info("Transformation options: Resize={0}, HFlip={1}, VFlip={2}", _config.Global.Resize, _config.Global.FlipHorizontally, _config.Global.FlipVertically); // 2-bit graph if (_colorize && _gray2Colorizer != null) { _graphs.Add(new RenderGraph { Name = "2-bit Colored VPM Graph", Source = _vpmGray2Source, Destinations = renderers, Converter = _gray2Colorizer, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); ReportingTags.Add("Color:Gray2"); } else { _graphs.Add(new RenderGraph { Name = "2-bit VPM Graph", Source = _vpmGray2Source, Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); } // 4-bit graph if (_colorize && _gray4Colorizer != null) { _graphs.Add(new RenderGraph { Name = "4-bit Colored VPM Graph", Source = _vpmGray4Source, Destinations = renderers, Converter = _gray4Colorizer, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); ReportingTags.Add("Color:Gray4"); } else { _graphs.Add(new RenderGraph { Name = "4-bit VPM Graph", Source = _vpmGray4Source, Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); } // rgb24 graph _graphs.Add(new RenderGraph { Name = "RGB24-bit VPM Graph", Source = _vpmRgb24Source, Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); // alphanumeric graph _graphs.Add(new RenderGraph { Name = "Alphanumeric VPM Graph", Source = _vpmAlphaNumericSource, Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); if (_colorize && (_gray2Colorizer != null || _gray4Colorizer != null)) { Logger.Info("Just clearing palette, colorization is done by converter."); _graphs.ClearColor(); } else if (_colorize && _palette != null) { Logger.Info("Applying palette to render graphs."); _graphs.ClearColor(); if (_coloring != null) { _graphs.SetPalette(_palette, _coloring.DefaultPaletteIndex); } else { _graphs.SetPalette(_palette, -1); } } else { Logger.Info("Applying default color to render graphs ({0}).", _color); _graphs.ClearPalette(); _graphs.SetColor(_color); } _graphs.Init().StartRendering(); }