Exemple #1
0
        public NetpbmImage <TPixelFormat> ReadImageData <TPixelFormat>(Stream stream, NetpbmHeader <TPixelFormat> header,
                                                                       IImageFactory <TPixelFormat> imageFactory)
        {
            IEnumerable <IEnumerable <TPixelFormat> > data;

            switch (header.ImageType)
            {
            case ImageType.PlainPBM:
            case ImageType.PBM:
                data = ReadPBMData(stream, header, imageFactory);
                break;

            case ImageType.PlainPGM:
            case ImageType.PGM:
            case ImageType.PlainPPM:
            case ImageType.PPM:
                data = ReadPGMOrPPMData(stream, header, imageFactory);
                break;

            case ImageType.PAM:
            case ImageType.BigPAM:
                data = ReadPAMData(stream, header, imageFactory);
                break;

            default:
                throw new ArgumentOutOfRangeException("header.ImageType", header.ImageType, "unknown image type");
            }

            return(imageFactory.MakeImage(header, data));
        }
Exemple #2
0
        /// <summary>
        /// Refreshes file metadata like size, dimensions etc.
        /// </summary>
        /// <param name="stream">The file stream (can be null)</param>
        public static void RefreshMetadata(this MediaFile file, Stream stream, IImageFactory imageFactory)
        {
            Guard.NotNull(file, nameof(file));

            file.Size      = stream != null ? (int)stream.Length : 0;
            file.Width     = null;
            file.Height    = null;
            file.PixelSize = null;

            if (stream != null && file.MediaType == MediaType.Image)
            {
                try
                {
                    var size = ImageHeader.GetPixelSize(stream, file.MimeType);
                    file.Width     = size.Width;
                    file.Height    = size.Height;
                    file.PixelSize = size.Width * size.Height;
                }
                catch
                {
                    // Don't attempt again
                    file.Width     = 0;
                    file.Height    = 0;
                    file.PixelSize = 0;
                }
            }
        }
Exemple #3
0
        public static IImage FromFile(this IImageFactory imageFactory, string filePath)
        {
            IFileFormat imageFormat = FileFormatFactory.Default.FromFile(filePath);

            using (Stream stream = File.OpenRead(filePath))
                return(imageFactory.FromStream(stream, imageFormat));
        }
 public ImageController(IImageFactory fac, IGridFactory gridFac)
 {
     _factory     = fac;
     _gridFactory = gridFac;
     //This can be created from request params
     _grid = _gridFactory.CreateGrid(60, 60, 10);
 }
 public ImageController(IImageDataProvider imageDataProvider, IImageFactory imageFactory, IImageRepository imageRespository, IImageUrlProvider imageUrlProvider)
 {
     _imageDataProvider = imageDataProvider;
     _imageFactory = imageFactory;
     _imageRespository = imageRespository;
     _imageUrlProvider = imageUrlProvider;
 }
Exemple #6
0
        public TrackRenderer(ITrackParameters trackParameters, IGameParameters gameParameters, IImageFactory imageFactory, ITrackPathBuilder trackPathBuilder)
        {
            _trackParameters = trackParameters;
            _gameParameters  = gameParameters;
            _imageFactory    = imageFactory;

            _cornerTrackPath       = trackPathBuilder.BuildCornerTrackPath();
            _cornerPlankPath       = trackPathBuilder.BuildCornerPlankPath();
            _cornerSinglePlankPath = trackPathBuilder.BuildCornerPlankPath(1);
            _horizontalTrackPath   = trackPathBuilder.BuildHorizontalTrackPath();
            _horizontalPlankPath   = trackPathBuilder.BuildHorizontalPlankPath();

            _plankPaint = new PaintBrush
            {
                Color       = Colors.Black,
                Style       = PaintStyle.Stroke,
                StrokeWidth = _trackParameters.PlankWidth,
                IsAntialias = true
            };
            _trackClear = new PaintBrush
            {
                Color       = Colors.White,
                Style       = PaintStyle.Stroke,
                StrokeWidth = _trackParameters.RailTopWidth,
                IsAntialias = true
            };
            _trackEdge = new PaintBrush
            {
                Color       = Colors.Black,
                Style       = PaintStyle.Stroke,
                StrokeWidth = _trackParameters.RailWidth,
                IsAntialias = true
            };
        }
        public override ToolStripItem[] GetMenuItems(IImageFactory imageFactory)
        {
            var items = new List <ToolStripItem>();

            var item = new ToolStripMenuItem(_command.Text);

            item.Click += item_Click;

            if (!string.IsNullOrEmpty(_imageName))
            {
                item.Image = imageFactory.GetImageByUri(new Uri(_imageName));
            }

            if (_seperatorAbove)
            {
                items.Add(new ToolStripSeparator());
            }

            items.Add(item);

            if (_seperatorBelow)
            {
                items.Add(new ToolStripSeparator());
            }

            return(items.ToArray());
        }
 public ImageDataSource(IImagePointerDataSource dataSource, IImageFactory imageFactory)
     : base(dataSource)
 {
     this.writeableBitmap = new WriteableBitmap(dataSource.Width, dataSource.Height, 96, 96, PixelFormats.Bgr24, null);
     this.CurrentValue    = writeableBitmap;
     this.size            = new IntSize(dataSource.Width, dataSource.Height);
     this.imageFactory    = imageFactory;
 }
        public TerrainMapRenderer(ITerrainMap terrainMap, IImageFactory imageFactory, IImageCache imageCache, IPixelMapper pixelMapper)
        {
            _terrainMap   = terrainMap;
            _imageFactory = imageFactory;
            _imageCache   = imageCache;
            _pixelMapper  = pixelMapper;

            _terrainMap.CollectionChanged += (s, e) => _imageCache.SetDirty(this);
        }
        public override ToolStripItem[] GetMenuItems(IImageFactory imageFactory)
        {
            var item = new ToolStripMenuItem(Name);
            item.Tag = this;

            item.DropDownItems.AddRange(base.GetMenuItems(imageFactory));

            return new ToolStripItem[] {item};
        }
Exemple #11
0
 /// <summary>
 /// Constructor for the ImageManager class
 /// </summary>
 /// <param name="pDict">passed in dictionary to remove responsibility for creating the collection</param>
 /// <param name="pImageFactory">passed in IImageFactory, removing responsibility for creating the factory</param>
 /// <param name="pProcesssor">passed in IImageProcessor, removing responsibility for creating the processor</param>
 public ImageManager(IDictionary <string, Image> pDict, IImageFactory pImageFactory, IImageProcessor pProcesssor)
 {
     //set _imageFact equal to pImageFactory
     _imageFact = pImageFactory;
     //set _imageProcessor equal to pProcessor
     _imageProcessor = pProcesssor;
     //set _imageDict equal to pDict
     _imageDict = pDict;
 }
Exemple #12
0
        public StaticEntityCollectionRenderer(ILayout <T> layout, IEnumerable <IStaticEntityRenderer <T> > renderers, IImageFactory imageFactory, IImageCache imageCache)
        {
            _layout       = layout;
            _renderers    = renderers;
            _imageFactory = imageFactory;
            _imageCache   = imageCache;

            layout.CollectionChanged += (s, e) => Changed?.Invoke(this, EventArgs.Empty);
        }
 public Model()
 {
     // INSTANTIATE '_images' as a new Dictionary to store a key and an Image object:
     _images = new Dictionary <string, Image>();
     // INSTANTIATE '_manipulator' as an instance of ImageManipulator:
     _manipulator = new ImageManipulator();
     // INSTANTIATE '_imageFactory' as an instance of ImageFactory:
     _imageFactory = new ImageFactory();
 }
Exemple #14
0
        public HomeModule(IImageFactory imageFactory)
        {
            _imageFactory = imageFactory;

            Get[@"{height}/{width}"] = GetImageStream;

            Get[@"{query}/{height}/{width}"] = GetImageStream;

            Get[@"/"] = args => View["index.htm"];
        }
Exemple #15
0
 private IEnumerable <TPixelFormat> ReadPlainRow <TPixelFormat>(Stream stream, int componentCount, bool finalRow,
                                                                IImageFactory <TPixelFormat> imageFactory)
 {
     for (int i = 0; i < componentCount; ++i)
     {
         var valueBytes  = SkipWhitespaceAndReadUntilNextWhitespaceByte(stream, !finalRow || i < componentCount - 1);
         var valueString = GetUsAsciiString(valueBytes);
         yield return(imageFactory.ParseComponentValue(valueString));
     }
 }
        public override void Init()
        {
            base.Init();

            jpegDecoder = new JpegFactory(80).Pipe(new JpegCodec());
            pngDecoder  = new PngFactory().Pipe(new PngCodec());

            metadataDecoder  = new JsonFactory <MetadataResponse>();
            geocodingDecoder = new JsonFactory <GeocodingResponse>();
        }
Exemple #17
0
        public override ToolStripItem[] GetMenuItems(IImageFactory imageFactory)
        {
            var item = new ToolStripMenuItem(Name);

            item.Tag = this;

            item.DropDownItems.AddRange(base.GetMenuItems(imageFactory));

            return(new ToolStripItem[] { item });
        }
        public override ToolStripItem[] GetMenuItems(IImageFactory imageFactory)
        {
            var items = new List<ToolStripItem>();

            foreach (IMenuModel model in _models)
            {
                items.AddRange(model.GetMenuItems(imageFactory));
            }

            return items.ToArray();
        }
 public CarNumberController(
     IImageFactory imageFactory, 
     ICarNumerIdentifyService identifyService, 
     IImageRepository imageRepository,
     IImageUrlProvider imageUrlProvider)
 {
     _imageFactory = imageFactory;
     _identifyService = identifyService;
     _imageRepository = imageRepository;
     _imageUrlProvider = imageUrlProvider;
 }
 public ImageProcessorsController(
     IImageRepository imageRepository,
     IImageProcessorsService imageProcessorService,
     IImageFactory imageFactory,
     IImageUrlProvider imageUrlProvider)
 {
     _imageRepository = imageRepository;
     _imageProcessorService = imageProcessorService;
     _imageFactory = imageFactory;
     _imageUrlProvider = imageUrlProvider;
 }
        public override ToolStripItem[] GetMenuItems(IImageFactory imageFactory)
        {
            var items = new List <ToolStripItem>();

            foreach (IMenuModel model in _models)
            {
                items.AddRange(model.GetMenuItems(imageFactory));
            }

            return(items.ToArray());
        }
        public override ToolStripItem[] GetMenuItems(IImageFactory imageFactory)
        {
            var items = new List <ToolStripItem>();

            foreach (ToolStripItem item in GenerateItems(imageFactory))
            {
                item.Tag = this;
                items.Add(item);
            }

            return(items.ToArray());
        }
Exemple #23
0
        public HarrisDetector(IComponentConfiguration componentConfiguration, IImageFactory factory,
            IImageConverter imageConverter, ICameraImageConverter cameraImageConverter)
        {
            cameraConverter = cameraImageConverter;
            converter = imageConverter;
            imageFactory = factory;
            configuration = componentConfiguration;

            UpdateDetector();

            configuration.ConfigurationChanged += OnConfigurationChanged;
        }
        public override ToolStripItem[] GetMenuItems(IImageFactory imageFactory)
        {
            var items = new List<ToolStripItem>();

            foreach (ToolStripItem item in GenerateItems(imageFactory))
            {
                item.Tag = this;
                items.Add(item);
            }

            return items.ToArray();
        }
 public ClusterLogic(
     IImageFactory imageFactory,
     Action <Pin, Marker> onMarkerCreating,
     Action <Pin, Marker> onMarkerCreated,
     Action <Pin, Marker> onMarkerDeleting,
     Action <Pin, Marker> onMarkerDeleted)
 {
     this.imageFactory     = imageFactory;
     this.onMarkerCreating = onMarkerCreating;
     this.onMarkerCreated  = onMarkerCreated;
     this.onMarkerDeleting = onMarkerDeleting;
     this.onMarkerDeleted  = onMarkerDeleted;
 }
Exemple #26
0
        public override IEnumerable <ToolStripItem> GenerateItems(IImageFactory imageFactory)
        {
            foreach (IPresenter presenter in _controller.Presenters)
            {
                string text    = ((DockContent)presenter.UntypedView).Text;
                bool   visible = _controller.IsVisible(presenter);

                var item = new ToolStripMenuItem(text);
                item.Checked = visible;

                yield return(item);
            }
        }
 public PinLogic(
     IImageFactory imageFactory,
     Action <Pin, Marker> onMarkerCreating,
     Action <Pin, Marker> onMarkerCreated,
     Action <Pin, Marker> onMarkerDeleting,
     Action <Pin, Marker> onMarkerDeleted)
 {
     _imageFactory     = imageFactory;
     _onMarkerCreating = onMarkerCreating;
     _onMarkerCreated  = onMarkerCreated;
     _onMarkerDeleting = onMarkerDeleting;
     _onMarkerDeleted  = onMarkerDeleted;
 }
Exemple #28
0
 public Audio(IRoadieSettings configuration,
              IHttpEncoder httpEncoder,
              IArtistFactory artistFactory,
              IReleaseFactory releaseFactory,
              IImageFactory imageFactory,
              ICacheManager cacheManager,
              ILogger logger,
              IArtistLookupEngine artistLookupEngine,
              IReleaseLookupEngine releaseLookupEngine,
              IAudioMetaDataHelper audioMetaDataHelper)
     : base(configuration, httpEncoder, artistFactory, releaseFactory, imageFactory, cacheManager, logger, artistLookupEngine, releaseLookupEngine)
 {
     this.AudioMetaDataHelper = audioMetaDataHelper;
 }
 public ImageUploadService(
     IConfigurationStorage configurationStorage,
     IImageRepository imageRepository,
     IThumbnailRepository thumbnailRepository,
     IIdGenerator imageIdGenerator,
     IClock clock,
     IHttpClientWrapper httpClient,
     IImageFactory imageFactory)
 {
     _configurationStorage = configurationStorage;
     _imageRepository      = imageRepository;
     _thumbnailRepository  = thumbnailRepository;
     _imageIdGenerator     = imageIdGenerator;
     _clock        = clock;
     _httpClient   = httpClient;
     _imageFactory = imageFactory;
 }
Exemple #30
0
 public TreeRenderer(IImageFactory imageFactory, IGameParameters gameParameters)
 {
     _cellSize      = gameParameters.CellSize;
     _centerOffset  = _cellSize / 2.0f;
     _baseRadius    = _cellSize / 4.0f;
     _minTreeSize   = _baseRadius;
     _maxTreeSize   = _baseRadius * 1.25f;
     _baseTreeBrush = new PaintBrush
     {
         Color = new Color("#1B633A"),
         Style = PaintStyle.Fill
     };
     _topTreeBrush = new PaintBrush
     {
         Color       = new Color("#236A42"),
         Style       = PaintStyle.Fill,
         IsAntialias = true
     };
     _imageFactory = imageFactory;
 }
        public override ToolStripItem[] GetMenuItems(IImageFactory imageFactory)
        {
            var items = new List<ToolStripItem>();

            var item = new ToolStripMenuItem(_command.Text);
            item.Click += item_Click;

            if (!string.IsNullOrEmpty(_imageName))
            {
                item.Image = imageFactory.GetImageByUri(new Uri(_imageName));
            }

            if (_seperatorAbove) items.Add(new ToolStripSeparator());

            items.Add(item);

            if (_seperatorBelow) items.Add(new ToolStripSeparator());

            return items.ToArray();
        }
Exemple #32
0
        public PicturesController(
            IImageGalleryService imageGalleryService,
            IImageFactory imageFactory,
            IDateProvider dateProvider,
            ILakeService lakeService,
            IImageGalleryFactory imageGalleryFactory,
            IDirectoryHelper directoryHelper)
        {
            Validator.ValidateForNull(imageGalleryService, paramName: "imageGalleryService");
            Validator.ValidateForNull(imageFactory, paramName: "imageFactory");
            Validator.ValidateForNull(dateProvider, paramName: "dateProvider");
            Validator.ValidateForNull(lakeService, paramName: "lakeService");
            Validator.ValidateForNull(imageGalleryFactory, paramName: "imageGalleryFactory");
            Validator.ValidateForNull(directoryHelper, paramName: "directoryHelper");

            this.imageGalleryService = imageGalleryService;
            this.imageFactory        = imageFactory;
            this.dateProvider        = dateProvider;
            this.lakeService         = lakeService;
            this.imageGalleryFactory = imageGalleryFactory;
            this.directoryHelper     = directoryHelper;
        }
Exemple #33
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += Application_ThreadException;

            var metadataDecoder   = new JsonFactory <MetadataResponse>();
            var geocodingDecoder  = new JsonFactory <GeocodingResponse>();
            var userProfile       = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            var assetsRoot        = Path.Combine(userProfile, "Box", "VR Initiatives", "Engineering", "Assets");
            var keyFileName       = Path.Combine(assetsRoot, "DevKeys", "google-streetview.txt");
            var gmapsCacheDirName = Path.Combine(assetsRoot, "GoogleMaps");
            var gmapsCacheDir     = new DirectoryInfo(gmapsCacheDirName);
            var cache             = new CachingStrategy
            {
                new FileCacheLayer(gmapsCacheDir)
            };

            var lines      = File.ReadAllLines(keyFileName);
            var apiKey     = lines[0];
            var signingKey = lines[1];

            gmaps = new GoogleMapsClient(
                apiKey, signingKey,
                metadataDecoder, geocodingDecoder,
                cache);

            imageDecoder = new GDICodec(MediaType.Image_Jpeg);

            form = new ImageViewer();
            form.LocationSubmitted += Form_LocationSubmitted;
            form.LatLngSubmitted   += Form_LatLngSubmitted;
            form.PanoSubmitted     += Form_PanoSubmitted;
            using (form)
            {
                Application.Run(form);
            }
        }
        public AudioMetaDataHelper(IRoadieSettings configuration, IHttpEncoder httpEncoder, IRoadieDbContext context, IMusicBrainzProvider musicBrainzHelper,
                                   ILastFmHelper lastFmHelper, ICacheManager cacheManager, ILogger logger, IArtistLookupEngine artistLookupEngine,
                                   IImageFactory imageFactory, IFileNameHelper filenameHelper, IID3TagsHelper id3TagsHelper)
        {
            this.Configuration  = configuration;
            this.HttpEncoder    = httpEncoder;
            this.CacheManager   = cacheManager;
            this.Logger         = logger;
            this.ImageFactory   = ImageFactory;
            this.FileNameHelper = filenameHelper;
            this.ID3TagsHelper  = id3TagsHelper;

            this.MusicBrainzProvider = musicBrainzHelper;
            this.LastFmHelper        = lastFmHelper;

            this.ArtistLookupEngine = artistLookupEngine;

            this.DoParseFromFileName = configuration.Processing.DoParseFromFileName;
            this.DoParseFromDiscogsDBFindingTrackForArtist = configuration.Processing.DoParseFromDiscogsDBFindingTrackForArtist;
            this.DoParseFromDiscogsDB   = configuration.Processing.DoParseFromDiscogsDB;
            this.DoParseFromMusicBrainz = configuration.Processing.DoParseFromMusicBrainz;
            this.DoParseFromLastFM      = configuration.Processing.DoParseFromLastFM;
        }
Exemple #35
0
        public Game(IGameBoard gameBoard,
                    IEnumerable <ILayerRenderer> boardRenderers,
                    IPixelMapper pixelMapper,
                    IImageFactory imageFactory,
                    ITimer renderLoop,
                    IEnumerable <IScreen> screens,
                    IImageCache imageCache)
        {
            _gameBoard      = gameBoard;
            _boardRenderers = boardRenderers;
            _pixelMapper    = pixelMapper;
            _imageFactory   = imageFactory;
            _renderLoop     = renderLoop;
            _screens        = screens;
            _imageCache     = imageCache;

            foreach (IScreen screen in _screens)
            {
                screen.Changed += (s, e) => _imageCache.SetDirty(screen);
            }
            foreach (ICachableLayerRenderer renderer in _boardRenderers.OfType <ICachableLayerRenderer>())
            {
                renderer.Changed += (s, e) => _imageCache.SetDirty(renderer);
            }

            _renderLayerDrawTimes         = _boardRenderers.ToDictionary(x => x, x => InstrumentationBag.Add <ElapsedMillisecondsTimedStat>(GetLayerDiagnosticsName(x)));
            _screenDrawTimes              = _screens.ToDictionary(x => x, x => InstrumentationBag.Add <ElapsedMillisecondsTimedStat>(GetLayerDiagnosticsName(x)));
            _renderCacheDrawTimes         = _boardRenderers.Where(x => x is ICachableLayerRenderer).ToDictionary(x => x, x => InstrumentationBag.Add <ElapsedMillisecondsTimedStat>("Draw-Cache-" + x.Name.Replace(" ", "")));
            _pixelMapper.ViewPortChanged += (s, e) => _imageCache.SetDirtyAll(_boardRenderers);

            _renderLoop.Elapsed += (s, e) => DrawFrame();
            _renderLoop.Interval = RenderInterval;
            _renderLoop.Start();

            _gameBoard.Initialize(_pixelMapper.Columns, _pixelMapper.Rows);
        }
 protected MenuStripPresenterBase(IMenuRegistry menuRegistry, IImageFactory imageFactory)
 {
     _menuRegistry = menuRegistry;
     _imageFactory = imageFactory;
 }
 public ToolStripMenuPresenter(ToolStrip menu, IMenuRegistry menuRegistry, IImageFactory imageFactory)
     : base(menuRegistry, imageFactory)
 {
     _menu = menu;
 }
 public MenuStripPresenter(MenuStrip menu, IMenuRegistry menuRegistry, IImageFactory imageFactory)
     : base(menuRegistry, imageFactory)
 {
     _menu = menu;
 }
 public ImageRepository(IImageDataProvider imageDataProvider, IImageFactory imageFactory)
 {
     _imageDataProvider = imageDataProvider;
     _imageFactory = imageFactory;
 }
 public DefaultImageProcessor(IImageFactory imageFactory, IEventPublisher eventPublisher)
 {
     Factory         = imageFactory;
     _eventPublisher = eventPublisher;
 }
Exemple #41
0
 public ImageRepository(IImageDataProvider imageDataProvider, IImageFactory imageFactory)
 {
     _imageDataProvider = imageDataProvider;
     _imageFactory      = imageFactory;
 }
Exemple #42
0
 public CachableLayoutRenderer(ILayout <T> layout, IRenderer <T> renderer, IImageFactory imageFactory)
     : base(layout, renderer, imageFactory)
 {
     layout.CollectionChanged += (s, e) => _dirty = true;
 }
 public abstract IEnumerable<ToolStripItem> GenerateItems(IImageFactory imageFactory);
 public abstract ToolStripItem[] GetMenuItems(IImageFactory imageFactory);