Click here to Skip to main content
15,883,925 members
Articles / Web Development / ASP.NET

Dynamic DeepZoom ASP.NET User Control using Seadragon

Rate me:
Please Sign up or sign in to vote.
5.00/5 (11 votes)
19 May 2010CPOL4 min read 88K   2.3K   10  
A deepzoom user control doesn't need to generate deepzoom image files
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DeepZoom.ascx.cs" Inherits="DeepZoom" %>
<div id="container" runat="server" style="width: 400px; height: 300px; background-color: black;">
    <input id="width" type="hidden" runat="server" />
    <input id="height" type="hidden" runat="server" />
    <input id="imageUrl" type="hidden" runat="server" />
    <input id="tileSize" type="hidden" runat="server" value="256" />
    <input id="tileOverlap" type="hidden" runat="server" value="1" />
</div>
<script type="text/javascript" src="http://seadragon.com/ajax/0.8/seadragon-min.js"></script>
<script type="text/javascript">
    function Init() {
        var width = parseInt(document.getElementById("<%= width.ClientID %>").value);
        var height = parseInt(document.getElementById("<%= height.ClientID %>").value);
        var imageUrl = document.getElementById("<%= imageUrl.ClientID %>").value;
        var tileSize = parseInt(document.getElementById("<%= tileSize.ClientID %>").value);
        var tileOverlap = parseInt(document.getElementById("<%= tileOverlap.ClientID %>").value);
        var tileSource = new Seadragon.TileSource(width, height, tileSize, tileOverlap);
        tileSource.getTileUrl = function (level, x, y) {
            return "GetTileImage.ashx?level=" + level + "&x=" + x + "&y=" + y +
                   "&tileSize=" + tileSize + "&tileOverlap=" + tileOverlap + "&image=" + imageUrl;
        }

        var container = document.getElementById("<%= container.ClientID %>");
        var viewer = new Seadragon.Viewer(container);
        viewer.openTileSource(tileSource);
    }

    Seadragon.Utils.addEvent(window, "load", Init);
</script>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions