zoukankan      html  css  js  c++  java
  • SilverLight For Arcgis 导出图片保存到本地注意点。。。

    参考出处:http://bbs.esrichina-bj.cn/ESRI/thread-59271-1-1.html 

    使用上面提供的方法需要注意的地方:

    1:url路径可能不对需要自己根据情况调整下。

    2:有的图层可能需要传入token

    GetUrl方法需要修改 

      private static string GetUrl(PrintArea area, string url,string token)

        {

            StringBuilder uri = new StringBuilder();

            uri.AppendFormat("{0}/export?", url);

            uri.AppendFormat(System.Globalization.CultureInfo.InvariantCulture,

                "bbox={0},{1},{2},{3}", area.XMin, area.YMin, area.XMax, area.YMax);

            uri.AppendFormat("&size={0},{1}", area.Width, area.Height);

            uri.Append("&format=png32");

            uri.Append("&transparent=true");

            if (area.SpatialReferenceID.HasValue)

            {

                uri.AppendFormat("&imageSR={0}&bboxSR={0}", area.SpatialReferenceID);

            }

            uri.Append("&f=image");

            uri.Append("&token=" + token);

            return uri.ToString();

        } 

    3 .奖生成的图片转成stream的时候要用ImageFormat.Png,如果是mageFormat.jpeg那么所有透明的地方都会被黑色替代

                MemoryStream stream = new MemoryStream();

                image.Save(stream, ImageFormat.Png);

                byte[] data = new byte[(int)stream.Length]; 

    4:下载图片

            protected void Button1_Click(object sender, EventArgs e)

            {

                WebClient client = new WebClient();

                string id = Request.QueryString[0];

                string url = "http://" + Request.Url.Authority + "/GetImagePrint.ashx?id="+id;

                WebClient wc = new WebClient();

                var bytes = wc.DownloadData(url);


                Response.Buffer = true;

                Page.Response.Clear();//清除缓冲区所有内容

                Page.Response.ContentType = "application/octet-stream";

                Page.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("print.jpg"));

                byte[] file = bytes;

                int a = file.Length;

                Response.BinaryWrite(file);

                Response.Flush();

                Response.End();

            } 

    QQ群:1022985150 VX:kklldog 一起探讨学习.NET技术
    作者:Agile.Zhou(kklldog)
    出处:http://www.cnblogs.com/kklldog/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    IBM X System ServerGuide 8.41 服务器 系统安装 引导盘
    oracle查找重复记录
    linux的nohup命令的用法。
    最佳设计工作流
    开发的浏览器颠覆微软,引爆了一场互联网大战
    程序员的成长和代码行数的关系
    Oracle SQL Developer 连接 MySQL
    Linux 如何打开端口
    SQLSERVER中如何快速比较两张表的不一样
    我所理解的MVVM
  • 原文地址:https://www.cnblogs.com/kklldog/p/1835982.html
Copyright © 2011-2022 走看看