/// <summary> /// /// </summary> /// <param name="session"></param> /// <param name="canvas"></param> /// <param name="fname"></param> /// <param name="args"> /// 支持各种类型的多个参数 /// 其中string[]类型的数据会作为RasterDrawing的options /// </param> /// <returns></returns> public static IRasterLayer CreateAndLoadRasterLayer(ISmartSession session, ICanvas canvas, string fname, params object[] args) { //bool isImage = IsImage(fname); //IRasterDrawing drawing = new RasterDrawing(fname, canvas, isImage ? null : GetStretcherProvider(args)); string[] options = GetOptions(args); IRasterDrawing drawing = new RasterDrawing(fname, canvas, GetStretcherProvider(args), options); //此处应走配置文件 drawing.SelectedBandNos = GetDefaultBands(drawing); if (args != null && args.Length == 1 && args[0] is int[]) { drawing.SelectedBandNos = (int[])args[0]; } IRasterLayer rstLayer = new RasterLayer(drawing); canvas.LayerContainer.Layers.Add(rstLayer); canvas.PrimaryDrawObject = drawing; canvas.CurrentEnvelope = drawing.OriginalEnvelope; int w = drawing.DataProvider.Width; int h = drawing.DataProvider.Height; //小图像不显示进度条 int times = drawing.GetOverviewLoadTimes(); if (times == -1) { drawing.StartLoading(null); return(rstLayer); } string tipstring = "正在读取文件\"" + Path.GetFileName(fname) + "\"..."; try { session.ProgressMonitorManager.DefaultProgressMonitor.Reset(tipstring, times); session.ProgressMonitorManager.DefaultProgressMonitor.Start(false); drawing.StartLoading((t, p) => { session.ProgressMonitorManager.DefaultProgressMonitor.Boost(p, tipstring); }); } finally { session.ProgressMonitorManager.DefaultProgressMonitor.Finish(); } return(rstLayer); }
private void AddRasterLayer(string strRasName) { if (_isOnlyOneImg) { bool memoryIsEnough = CheckMemory(strRasName); if (!memoryIsEnough) { MsgBox.ShowInfo("系统可用内存不足以对以下文件执行几何精校正操作。\n\n" + strRasName); return; } } IRasterDrawing drawing = new RasterDrawing(strRasName, canvasHost1.Canvas, GetRgbStretcherProvider(strRasName)); drawing.SelectedBandNos = GetDefaultBands(drawing); IRasterLayer rstLayer = new RasterLayer(drawing); canvasHost1.Canvas.LayerContainer.Layers.Add(rstLayer); canvasHost1.Canvas.PrimaryDrawObject = drawing; canvasHost1.Canvas.CurrentEnvelope = drawing.OriginalEnvelope; int times = drawing.GetOverviewLoadTimes(); if (times == -1) { drawing.StartLoading(null); return; } string tipstring = "正在读取文件\"" + Path.GetFileName(_strRasterName) + "\"..."; try { _smartSession.ProgressMonitorManager.DefaultProgressMonitor.Reset(tipstring, times); _smartSession.ProgressMonitorManager.DefaultProgressMonitor.Start(false); drawing.StartLoading((t, p) => { _smartSession.ProgressMonitorManager.DefaultProgressMonitor.Boost(p, tipstring); }); } finally { _smartSession.ProgressMonitorManager.DefaultProgressMonitor.Finish(); } }
private void AddRasterLayer(string strRasName, ICanvas canvas, double minValue, double maxValue) { IRasterDrawing drawing = new RasterDrawing(strRasName, canvas, GetRgbStretcherProvider(strRasName)); drawing.SelectedBandNos = GetDefaultBands(drawing); Color[] colors = GetDefColors(200); ColorMapTable <double> colorTable = GetColorTable(colors, maxValue, minValue); if (colorTable == null) { return; } drawing.ApplyColorMapTable(colorTable); IRasterLayer rstLayer = new RasterLayer(drawing); canvas.LayerContainer.Layers.Add(rstLayer); canvas.PrimaryDrawObject = drawing; canvas.CurrentEnvelope = drawing.OriginalEnvelope; int times = drawing.GetOverviewLoadTimes(); if (times == -1) { drawing.StartLoading(null); return; } string tipstring = "正在读取文件\"" + Path.GetFileName(strRasName) + "\"..."; try { _smartSession.ProgressMonitorManager.DefaultProgressMonitor.Reset(tipstring, times); _smartSession.ProgressMonitorManager.DefaultProgressMonitor.Start(false); drawing.StartLoading((t, p) => { _smartSession.ProgressMonitorManager.DefaultProgressMonitor.Boost(p, tipstring); }); } finally { _smartSession.ProgressMonitorManager.DefaultProgressMonitor.Finish(); } }