protected override void CreateRenderGraphs(RenderGraphCollection graphs, HashSet <string> reportingTags) { // define source object source; switch (Path.GetExtension(_options.FileName.ToLower())) { case ".png": case ".jpg": source = new ImageSourceBitmap(_options.FileName); break; case ".gif": source = new GifSource(_options.FileName); break; case ".bin": source = new RawSource(_options.FileName); break; default: throw new UnknownFormatException("Unknown format " + Path.GetExtension(_options.FileName.ToLower()) + ". Known formats: png, jpg, gif, bin."); } // define renderers var renderers = GetRenderers(_config, reportingTags); var frameSource = source as ISource; if (frameSource != null) { // chain them up graphs.Add(new RenderGraph { Source = frameSource, Destinations = renderers, Resize = _config.Global.Resize, FlipHorizontally = _config.Global.FlipHorizontally, FlipVertically = _config.Global.FlipVertically }); return; } // not an ISource, so it must be a IRawSource. var rawSource = (IRawSource)source; IRawOutput rawOutput = null; foreach (var dest in renderers.OfType <IRawOutput>()) { if (rawOutput != null) { throw new MultipleRawSourcesException("Cannot use multiple destinations when using a raw source."); } rawOutput = dest; } if (rawOutput == null) { throw new NoRawDestinationException("No device supporting raw data available."); } graphs.Add(new RawRenderer(rawSource, rawOutput)); }
protected override void CreateRenderGraphs(RenderGraphCollection graphs) { // define renderers var renderers = GetRenderers(_config); // 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); }