public DirectBitmap GenerateConstantColorTile(Color color)
        {
            var bitmap = new DirectBitmap(_pixelSize, _pixelSize);

            FlatTileRenderer.RenderToBitmap(color, bitmap);
            return(bitmap);
        }
        public TileGenerator(IConfigSource config)
        {
            var tileInfo = config.Configs["MapTileInfo"];

            _pixelSize = tileInfo?.GetInt("PixelScale", Constants.PixelScale) ?? Constants.PixelScale;
            var rendererName = tileInfo?.GetString("RenderTechnique", Constants.RenderTechnique) ?? Constants.RenderTechnique;

            switch (rendererName.ToLowerInvariant())
            {
            case "obbrenderer":
                _regionRenderer = new OBBRenderer(config);
                break;

            default:
                LOG.Error($"Unknown renderer '{rendererName}', defaulting to 'OBBRenderer'.");
                _regionRenderer = new OBBRenderer(config);
                break;
            }

            _flatRenderer = new FlatTileRenderer(config);

            var oceanOverlayPath = tileInfo?.GetString("OceanOverlay", Constants.OceanOverlay) ?? Constants.OceanOverlay;

            var pixelScale = tileInfo?.GetInt("PixelScale", Constants.PixelScale) ?? Constants.PixelScale;

            if (!string.IsNullOrWhiteSpace(oceanOverlayPath))
            {
                try {
                    var overlay = new Bitmap(Image.FromFile(oceanOverlayPath));

                    _oceanOverlay = new Bitmap(pixelScale, pixelScale);

                    using (var gfx = Graphics.FromImage(_oceanOverlay)) {
                        gfx.CompositingMode = CompositingMode.SourceCopy;
                        gfx.DrawImage(overlay, 0, 0, pixelScale, pixelScale);
                    }
                }
                catch (Exception e) {
                    LOG.Warn($"Error loading ocean overlay file '{oceanOverlayPath}', skipping.", e);
                }
            }
        }