Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Dynamic DeepZoom ASP.NET User Control using Seadragon

, 19 May 2010 CPOL
A deepzoom user control doesn't need to generate deepzoom image files
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.ComponentModel;

public partial class DeepZoom : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    public string ImageUrl
    {
        get { return imageUrl.Value; }
        set
        {
            Bitmap bmp = GetTileImage.LoadImage(value);
            if (bmp == null)
                return;

            imageUrl.Value = value;
            int cx = bmp.Width;
            int cy = bmp.Height;
            int n = (int)Math.Ceiling(Math.Log(Math.Max(cx, cy), 2)) + 1;
            int size = (int)Math.Pow(2, n);

            if (cx > cy)
            {
                width.Value = size.ToString();
                height.Value = (size * cy / cx).ToString();
            }
            else
            {
                width.Value = (size * cx / cy).ToString();
                height.Value = size.ToString();
            }
        }
    }

    [Bindable(true), Category("Appearance"), DefaultValue("400px")]
    public Unit Width
    {
        get { return Unit.Parse(container.Style["width"]); }
        set { container.Style["width"] = value.ToString(); }
    }
    [Bindable(true), Category("Appearance"), DefaultValue("300px")]
    public Unit Height
    {
        get { return Unit.Parse(container.Style["height"]); }
        set { container.Style["height"] = value.ToString(); }
    }
    [Bindable(true), Category("Appearance"), DefaultValue("256")]
    public int TileSize
    {
        get { return int.Parse(tileSize.Value); }
        set { tileSize.Value = value.ToString(); }
    }
    [Bindable(true), Category("Appearance"), DefaultValue("1")]
    public int TileOverlap
    {
        get { return int.Parse(tileOverlap.Value); }
        set { tileOverlap.Value = value.ToString(); }
    }
}

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)

Share

About the Author

Lang Deng
Web Developer
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 20 May 2010
Article Copyright 2010 by Lang Deng
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid