ConnectToSDE connectToSDE = new ConnectToSDE("59.64.154.185", "5152", "sde", "sde", "", "sde.DEFAULT");
try
{
connectToSDE.Connect();
IFeatureWorkspace featureWsp = (IFeatureWorkspace)connectToSDE.WorkSpace;
IFeatureClass featureClass = featureWsp.OpenFeatureClass("C400100");
//IFeatureDataset featureDataset = featureWsp.OpenFeatureDataset("Clip4001");
//IFeatureWorkspace featureWsp2 = (IFeatureWorkspace)featureDataset.Workspace;
//IFeatureClass featureClass = featureWsp2.OpenFeatureClass("C400100");
IFeatureLayer featureLayer = new FeatureLayerClass();
featureLayer.FeatureClass = featureClass;
IDataset dataSet = (IDataset)featureClass;
featureLayer.Name = dataSet.Name;
IMap map = new MapClass();
map.AddLayer((ILayer)featureLayer);
IActiveView activeview = (IActiveView)map;
IExportJPEG exportjpg = new ExportJPEGClass();
exportjpg.ProgressiveMode = false;
exportjpg.Quality = 100;
IExportImage exportimg = (IExportImage)exportjpg;
exportimg.ImageType = esriExportImageType.esriExportImageTypeTrueColor;
exportimg.Width = 400;
exportimg.Height = 300;
IRgbColor iColor = new RgbColorClass();
iColor.Red = 255;
iColor.Blue = 255;
iColor.Green = 255;
exportimg.BackgroundColor = iColor;//背景为白色
IWorldFileSettings iWFS = (IWorldFileSettings)exportimg;
iWFS.OutputWorldFile = false;
IExport export = (IExport)iWFS;
export.Resolution = 96; //activeview.ScreenDisplay.DisplayTransformation.Resolution;
tagRECT userRECT;
userRECT.top = 0;
userRECT.left = 0;
userRECT.right = ConvertRWToPixels(activeview.FullExtent.Width, activeview);//地理坐标向MAP容器坐标的转化
userRECT.bottom = ConvertRWToPixels(activeview.FullExtent.Height, activeview);//地理坐标向MAP容器坐标的转化
export.ExportFileName = "E:\\VS 2005\\WebServiceTest\\WebServiceTest\\Output\\Clip4001.jpg";
int hDc;
hDc = export.StartExporting();//由MAP容器向图片文件输出
activeview.Output(hDc, 96, ref userRECT, activeview.FullExtent, null);
export.FinishExporting();
}
来自:http://bbs.esrichina-bj.cn/esri/viewthread.php?action=printable&tid=17014