类似Google Earth的图片服务

//testhandler.ashx
public class TestHandler : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {

        if (context.Request.QueryString["nettype"] == "3")
        {
            context.Response.ContentType = "image/jpg";

            FileStream fs = new FileStream("d:\\test2.jpg", FileMode.Open);
            int length = (int)fs.Length;
            BinaryReader br = new BinaryReader(fs);
            byte[] buffer = br.ReadBytes(length);

            context.Response.OutputStream.Write(buffer, 0, buffer.Length);           
        }
        
else if (context.Request.QueryString["nettype"] == "4")
        {
            context.Response.ContentType = "image/png";

             //test imageservice..
            ImageServerLib.ImageService imgService = new ImageService();

            object imagedata;
            object imglen = imgService.QueryImage(out imagedata);

            byte[] buffer = (byte[])imagedata;
            int len = (int)imglen;

            context.Response.OutputStream.Write(buffer, 0, buffer.Length);
        }


    }
}

///

//default.aspx

<script language="javascript" type="text/javascript">
// <!CDATA[

function Button4_onclick() {
    //mynet.sendRequest("TestHandler.ashx?nettype=1", callback1);
    document.form1.img1.src = "TestHandler.ashx?nettype=3";
}

function Button5_onclick() {
    //mynet.sendRequest("TestHandler.ashx?nettype=1", callback1);
    document.form1.img1.src = "TestHandler.ashx?nettype=4";
}

// ]]>
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table runat="server">
        <tr> <td style="width: 496px; height: 202px">
            <input id="Button4" οnclick="return Button4_onclick()" type="button" value="button 4" />
            <input id="Button5" οnclick="return Button5_onclick()" type="button" value="button 5" />
            <uc1:WebUserControl ID="WebUserControl1" runat="server" width="100%" height="100%" Visible="true"/>
            <img id="img1" src="" /></td></tr>
        </table>
    </div>
    </form>
</body>
</html>

转载于:https://www.cnblogs.com/bigdaddy/archive/2008/06/12/1218575.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值