将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格式。。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2020-12-30 ArcGIS地理信息系统空间分析实验 数据
2020-12-30 tomcat缓存与数据库缓存的区别