Beispiel #1
0
            public TileScalerRunner(TileScaler baseScaler, string basePath, int zoom, Size renderScale, Size tileSize)
            {
                Scaler         = baseScaler;
                BasePath       = basePath;
                Zoom           = zoom;
                Scale          = 1 << Zoom;
                RegionTileSize = new Size((renderScale.Width * (1 << 9)) / Scale, (renderScale.Height * (1 << 9)) / Scale);
                TileSize       = tileSize;

                _timer = new Timer(TimerCallback, null, ExecInterval, ExecInterval);
            }
Beispiel #2
0
        public TileScaler(string basePath, Size renderScale, Size tileSize, int minZoom, int maxZoom, string levelId, string layerId)
        {
            LevelId = levelId;
            LayerId = layerId;
            var size = maxZoom - minZoom + 1;

            _runners = new TileScalerRunner[size];

            var i = 0;

            for (int z = minZoom; z <= maxZoom; z++)
            {
                _runners[i] = new TileScalerRunner(this, basePath, z, renderScale, tileSize);
                i++;
            }

            //Log.InfoFormat("TileScaler created with id {0} {1}->{2} ({3} - {4}) {5}", layerId, minZoom, maxZoom, tileSize, renderScale, basePath);
        }
Beispiel #3
0
        private void Load()
        {
            var size = new Size(Layer.Renderer.RenderScale.Width * (1 << 9),
                                Layer.Renderer.RenderScale.Height * (1 << 9));

            lock (_ioSync)
            {
                //Log.InfoFormat("Loading Tile {0},{1}@{2}", Position.X, Position.Z, Position.Zoom);
                Bitmap bitmap = null;
                if (File.Exists(FilePath))
                {
                    using (var fs = new FileStream(FilePath, FileMode.Open, FileAccess.ReadWrite))
                    {
                        using (var img = Image.FromStream(fs))
                        {
                            if (img.Width == size.Width && img.Height == size.Height)
                            {
                                bitmap = new Bitmap(img);
                            }
                        }
                    }
                }

                if (bitmap == null)
                {
                    bitmap = new Bitmap(size.Width, size.Height);
                    IsNew  = true;
                }

                lock (_bitmapSync)
                {
                    Bitmap       = bitmap;
                    BitmapBounds = new RectangleF(0, 0, Bitmap.Width, Bitmap.Height);
                    Graphics     = bitmap.GetGraphics();

                    if (IsNew)
                    {
                        Graphics.Clear(Layer.Renderer.Background);
                    }
                }
            }
        }