コード例 #1
0
        private void ShowGridLayerImage(string filename)
        {
            var layer = new GridLayer(filename);
            var image = filename = LayerImageGenerator.GenerateTemporaryImageFile(layer, "layer_", _richnessOptions.LowColor, _richnessOptions.HighColor, _richnessOptions.NoValueColor, 0, 255);

            SystemUtils.ShellExecute(image);
        }
コード例 #2
0
        private void ShowGridLayerInMap(GridLayer grid, int intervals, double cutoff, IGridLayerBitmapOptions options, string filename = null)
        {
            this.InvokeIfRequired(() => {
                var prefix = grid.Name;
                FileInfo f = new FileInfo(grid.Name);
                if (f.Exists)
                {
                    prefix = f.Name.Substring(0, f.Name.LastIndexOf("."));
                }

                var map = PluginManager.Instance.GetMap();

                if (filename == null)
                {
                    filename = LayerImageGenerator.GenerateTemporaryImageFile(grid, prefix, options.LowColor, options.HighColor, options.NoValueColor, cutoff, intervals);
                }
                else
                {
                    map.RemoveRasterLayer(filename);
                    LayerImageGenerator.CreateImageFileFromGrid(grid, filename, options.LowColor, options.HighColor, options.NoValueColor, cutoff, intervals);
                }


                map.Show();
                map.AddRasterLayer(filename);
            });
        }
コード例 #3
0
        public static string GenerateTemporaryImageFile(GridLayer layer, string filenamePrefix, Color lowcolor, Color highcolor, Color novaluecolor, double cutoff = 0, int intervals = 256)
        {
            var filename = TempFileManager.NewTempFilename("bmp", filenamePrefix);

            CreateImageFileFromGrid(layer, filename, lowcolor, highcolor, novaluecolor, cutoff, intervals);
            var image = LayerImageGenerator.GetImageForLayer(layer, lowcolor, highcolor, novaluecolor, cutoff, intervals);

            TempFileManager.Attach(filename + "w");
            return(filename);
        }
コード例 #4
0
        public static void CreateImageFileFromGrid(GridLayer layer, string filename, Color lowcolor, Color highcolor, Color novaluecolor, double cutoff = 0, int intervals = 256)
        {
            var image = LayerImageGenerator.GetImageForLayer(layer, lowcolor, highcolor, novaluecolor, cutoff, intervals);

            BitmapEncoder encoder = new BmpBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(image));
            if (File.Exists(filename))
            {
                try {
                    File.Delete(filename);
                } catch (Exception) {
                    // ignore
                }
            }

            using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write)) {
                encoder.Save(fs);
            }

            var worldFilename = filename + "w";

            CreateWorldFile(layer, worldFilename);
        }