思想有多远,我就能飞多远...... (致力于GIS方面的开发,希望每天能进步一点!)
IWorkspaceFactory pWorkspaceFactory; IRasterWorkspace pRasterWorkspace; OpenFileDialog openFileDialog2=new OpenFileDialog(); openFileDialog2.Filter="Layer File(*.lyr)|*.jpg;*.bmp;*.tiff"; openFileDialog2.Title="Open Map File"; openFileDialog2.ShowDialog(); //获取当前路径和文件名 string strFullPath=openFileDialog2.FileName; if(strFullPath=="") return; int Index=strFullPath.LastIndexOf("\\"); string fileName=strFullPath.Substring(Index+1); string filePath=strFullPath.Substring(0,Index); pWorkspaceFactory=new RasterWorkspaceFactoryClass(); pRasterWorkspace=(IRasterWorkspace)pWorkspaceFactory.OpenFromFile(filePath,0); IRasterDataset pRasterDataset=(IRasterDataset)pRasterWorkspace.OpenRasterDataset(fileName); IRasterLayer pRasterLayer= new RasterLayerClass(); pRasterLayer.CreateFromDataset(pRasterDataset); axMapControl1.Map.AddLayer(pRasterLayer);
posted on 2006-09-22 11:14 vakinglee 阅读(2908) 评论(7) 编辑 收藏 举报
Powered by: 博客园 Copyright © 2024 vakinglee Powered by .NET 8.0 on Kubernetes