我的github

将Map或Layout中的图象转出有两种方法,一种为通过IActiveView的OutPut函数,另外一种是通过IExport接口来实现。

参考:https://www.cnblogs.com/zhangjun1130/archive/2010/07/01/1768868.html(ArcGIS Engine开发系列:将地图导出为图片的两种方法(ZZ))

 

Image与byte[]之间的转换:https://www.cnblogs.com/wxm0827/p/11167170.html

            //Image image = new Bitmap(600, 600);
            //System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
            //tagRECT rect = deviceRect;
            //IEnvelope pEnvelope = pActiveView.Extent;
            //int dpi = pExporter.Resolution;
            //pActiveView.Output(g.GetHdc().ToInt32(), dpi, ref rect, pEnvelope, null);
            ////System.Diagnostics.Debugger.Launch();
            //image.Save("D:\\arcgisserver\\directories\\arcgisoutput\\xxx\\xxx_MapServer\\1.jpg");
            //byte[] bt = null;
            //Bitmap bmp = new Bitmap(image);
            //MemoryStream mostream = new MemoryStream();
            //bmp.Save(mostream, System.Drawing.Imaging.ImageFormat.Bmp);//将图像以指定的格式存入缓存内存流
            //bt = new byte[mostream.Length];
            //mostream.Position = 0;//设置留的初始位置
            //mostream.Read(bt, 0, Convert.ToInt32(bt.Length));
            //string imgbyte = Convert.ToBase64String(bt);//图片流转字符串
JSONObject json2 = new JSONObject();
json2.AddString("URL", imgbyte);
return Encoding.UTF8.GetBytes(json2.ToJSONString(null));

舍弃方法二:

            //ESRI.ArcGIS.Output.IExport export = null;
            //export = new ExportPNGClass();
            //export.ExportFileName = "D:\\arcgisserver\\directories\\arcgisoutput\\xxx\\xxx_MapServer\\1.png";
            //IEnvelope pEnvelope = pActiveView.Extent;
            ////导出参数           
            //export.Resolution = 96;
            //tagRECT exportRect = new tagRECT();
            //exportRect.left = exportRect.top = 0;
            //exportRect.right = 600;
            //exportRect.bottom = 600;
            //IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass();
            ////输出范围
            //envelope.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom);
            //export.PixelBounds = envelope;
            ////可用于取消操作
            ////获取handle
            //System.Int32 hDC = export.StartExporting();
            ////开始转出
            //pActiveView.Output(hDC, (System.Int16)export.Resolution, ref exportRect, pEnvelope, null);

测试成功:https://blog.csdn.net/kone0611/article/details/70311839/

测试成功;IExporter(牟乃夏-ArcGIS Engine地理信息系统开发教程——基于C#.NET Page220)但是IExporter不能保存为png格式。。

posted on 2021-12-30 09:45  XiaoNiuFeiTian  阅读(536)  评论(0编辑  收藏  举报