Scott Hanselman

Deep Zoom (Seadragon) Silverlight 2 MultiScaleImages at Mix

March 6, '08 Comments [22] Posted in Mix | Silverlight
Sponsored By

outrun One of the cool things seen at Mix 08 today was the Deep Zoom technology. This was originally called Seadragon and came out of the Live Labs research.

You can see it live at the Hard Rock Cafe Memorabilia site. This Silverlight application includes a tiled montage of 512 many-megapixel images, some 10+megapixels, while some are stitched together to sizes upwards of 40-50 megapixels, it seems.

Remember the first 3D games like Sega's OutRun? They seemed 3D, but basically bitmaps were being scaled as you "drove forward" and each graphical asset, like a house, for example, would have a number of pre-rendered versions. Another example are .ico files that have 16x16, 32x32, etc, versions. As the viewer there is one image, but there's multiple resolutions depending on how far in you want to zoom. This is the basic idea behind "multi-scale images."

You can see examples of exceedingly large images, often called "giga-pixel" images all over the web. A great example of zooming using Flash is at Harlem 13-Gigapixels.com. The large Harlem image is 2,045 individual images of 12 megapixels each. The rendering when zooming in is a lot like Google Earth. You zoom into an image of a specific resolution then that first image transitions into a tile of a second image rendered another resolution. You can create these kinds of images with Panorama stitching software like AutoPano.net, and PanoramaFactory. I took a large 50+ megapixel panorama of Ngorongoro Crater in Tanzania that I think would make a good example for this kind of thing. I'll dig it up and make a Deep Zoom example project.

DeepZoom includes an optimized local Silverlight Renderer and XAML control that makes creating these fairly easy. Try it out over at the HardRock Memorabilia site and take specific notice of this guitar I've circled in the picture below.

Hardrock Memorabilia

Zoom in...

image

And more...into the screw knob in the lower left corner...

image

You can actually see a reflection of the bench and the camera and Scott Stanfield from Vertigo who's taking the shot of this guitar, reflected in the shiny knob. Vertigo wrote the Hardrock site and they also have a great Deep Zoom Gallery.

Project Name

You can go download the Preview of the Deep Zoom Composer now. You can see its heritage when you make a new Project and it puts it in a folder called "Seadragon Projects." Here's the Deep Zoom Composer User Guide.

You place a number of pictures (or a large one) on the surface and export the collection. There will be a scene graph XML file created indicating location, size, z-order and aspect ratio of the images.

SparseImageSceneGraph.xml - Notepad

Then an output directory will be created with folders for each image and, depending on the relative largeness of the source images, a series of tiles generated a number of zoom levels. Here's an example directory structure:

11

Silverlight Project Test Page - Windows Internet Explorer (2)See how that image at zoom level 11 has 20 different tiles? They've got to balance many factors to make it all seamless. They're considering how many tiles are needed for that resolution as it relates to a zoom level's need for memory, as well as considering a reasonable number of requests to the server. There's the extreme need for a good user-experience so you want the images to come fast and furious, be easily cached and quickly shown to give the perception of speed. You don't have to sweat any of this stuff, as the multi-resolution tiles stitched together automatically by the client rendered.

After you've exported a project into these files, you create a MultiScale image in XAML like this, referencing a bin file manifest that knows contains info about the directory structure and files:

<MultiScaleImage x:Name="deepZoomObject" Source="foo/info.bin"/>

This gets you the image rendered. To zoom a MultiScaleImage, you call ZoomAboutLogicalPoint:

public void ZoomAboutLogicalPoint(double zoomIncrementFactor, double zoomCenterLogicalX, double zoomCenterLogicalY)

But there's a decent amount of state management that needs to be done as well as deciding how you want things animated, whether or not your image contains sub-images, etc. In the morning I'll take a look at how to hook up JavaScript events like Mouse Wheel Scrolls and do some zooming and panning. Hopefully Vertigo will release their hard-won source code for the canonical example to the community. It's pretty slick.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

ASP.NET MVC Preview 2 Screencast Tutorials

March 5, '08 Comments [44] Posted in ASP.NET | ASP.NET MVC | Learning .NET | Microsoft | Mix | Screencasts
Sponsored By

ASP.NET MVC Preview 2 released today and you can head over to http://www.asp.net/mvc to get the new stuff. I put together four new screencasts for this release.

I really feel that a well-done screencast is a great learning tool. Last month I did a survey of you all, Dear Reader, and got 1000 responses and published the results. I took all the comments, stats and general feedback and tried to improve these screencasts. As a result, I am more judicious in my use of PIP (Picture in Picture) and the screencasts are shorter and more to the point.

If you watched the original MVC Screencast, some of the content in videos #1 and #2 will be repeated as it's been updated for Preview 2, but I hope it doesn't waste your time. However, there's new things sprinkled around and a number of changes are called out. Additionally, videos 3 and 4 are completely new content. Video #4 talks about how to use a Mocking Framework to to TDD with MVC and #3 touches on a number of advanced techniques that you can practice at the Mix HOL (Hands-On-Labs).


#1 | MVC Preview - Part 1 - Displaying Data

16 minutes, 41 seconds

#2 | MVC Preview - Part 2 - Editing Data and Making Forms

18 minutes, 38 seconds

#3 | MVC Preview - Part 3 - Advanced Techniques

12 minutes, 56 seconds


#4 | MVC Preview - Part 4 - Testing

23 minutes, 20 seconds

UPDATE: There's only a template for MSTest in the new File | New MVC Project wizard right now because we're reaching out to the big Unit Testing libraries to get them to help create templates. If you have a Unit Testing Library, you can get into the MVC File | New Project dialog by packaging up your templates like this. I'd guess/hope that the installers for the major libraries would just include their templates in their next versions.

imageI'll work with Phil to get all the source to the apps in these videos posted soon. I hope you enjoy them as much as I enjoyed making them.

Note that while the player on the http://www.asp.net site is Silverlight, you can download versions on the same page in WMV format, as well as ones customized for the Zune, iPod, PSP, and MP4 and 3GP.

One other important new feature on the ASP.NET site is that Videos now accept comments and those comments include RSS feeds. Do feel free to leave comments on this blog, but you can also comment on videos and screencast tutorials all over the ASP.NET site. We all read these comments (including my boss) so your feedback IS paid attention to.

Technorati Tags: ,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Heading to Mix08 and Tweeting along the way

March 4, '08 Comments [4] Posted in Mix | Speaking
Sponsored By

image In the morning I'm heading to Mix. I'm going to be using Twitter as a microblog during my time at Mix. I'll post where I am and what I'm up to. You can sign up and "follow" me on Twitter, and select optional notifications via SMS or IM.

Scott Watermasysk has a great post called "Why Twitter" and I've been "tweeting" more and more of late. It's a great way to communicate, kind of like IRC except with permalinks and angle brackets. ;) Twitter is a lot more casual and there's a lot more off-the-cuff random discussions.

ScottWater has also setup a series of Hashtags such that any "tweets" on Twitter that include "#mix" "#mix08" in them will show up on this realtime feed. This is a great way to keep up on the hour by hour Mixiness that'll be going on, whether you're at the conference or not.

Also, if you haven't done your Mix Schedule, check out this ClickOnce WPF app that does Mix Scheduling. I'll be speaking on ASP.NET MVC on Thursday at 4:15 in Lando 4201 and Phil Haack and I will be hosting a Q&A in the Mix Open Spaces area immediately following.

I'll be looking to do a number of technical podcasts while in Vegas so if there's certain cool or obscure (or both) questions you want answered, leave them here and I'll try to chase them down. There's also a Mix category on my blog so posts while I'm there will be tagged as well.

See you in Vegas. Man, I hate this town.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

2008 Window Scripting Games - Advanced PowerShell Event 7

March 4, '08 Comments [25] Posted in Learning .NET | PowerShell | Ruby
Sponsored By

Olympic_flameIn a few days the 2008 Scripting Games will come to an end. This is a yearly event that the Script Center does. There's a beginner and an advanced division and a bunch of deceptively hard problems. I was selected to be on of the "Guest Commentators (list here)" which really means they wanted me to solve one of the problems and provide the solution as an example. I'm not sure my solution is the best way, but it did solve the problem they assigned me.

My problem was Event 7: Play Ball! and I was to write a script that schedules all the games for a round-robin baseball tournament. The complete scenario is here, but in a nutshell:

"In a round-robin baseball tournament (or any kind of round-robin tournament, for that matter), every team plays each of the other teams in the tournament one time and one time only. For example, suppose we have a tournament with three teams (teams A, B, and C). In that case, the tournament would consist of the following set of games:

  • A vs. B
  • A vs. C
  • B vs. C

See how that works? Team A plays Team B and Team C; Team B plays Team A and Team C; and Team C plays Teams A and B."

A few other wrinkles thrown in are that the games must be randomized, otherwise Team A will play too many in a row and you need to schedule six teams, A through F. Of course, to be clear, every team must pay every other team once and only once. Here's my solution, hacked together quickly.

#this only works with an even number of teams
cls
[array]$global:games = $nul
function rotateArray($a)
{
 $first, $rest = $a
 $a = $rest + $first
 return $a
}
function makeGames($a)
{
 $i = 0;
 while($i -lt $a.Length/2)
 {
  $global:games = $global:games + ($a[$i].ToString() + " vs. " + $a[$a.Length-1-$i].ToString())
  $i++
 }  
}
$a = "A","B","C","D","E","F"
$z = 0
while($z -lt $a.Length-1)
{
 makeGames($a)
 # hold on to the first one
 
 $first, $rest = $a
 #rotate the rest
 $rest = rotateArray($rest)
 $a = [array]$first + $rest
 $z++
}
#randomize games
$a = [collections.arraylist]$global:games
$r = $a.count..1 |% {$R = new-object random}{$R.next(0,$a.count) |%{$a[$_];$a.removeat($_)}}
$r

Doing this in PowerShell took my brain a while to get. Note the RotateArray method's use of multi-variable assignment to chop up he array into first and rest. That wasn't obvious to me as a C-guy for the last 15 years, but it made my solution simpler when I refactored and introduced it.

The solution (remember, it's randomized) will look something like this:

B vs. D
B vs. C
A vs. D
B vs. F
C vs. D
A vs. F
A vs. B
C vs. F
E vs. F
A vs. E
D vs. F
B vs. E
D vs. E
A vs. C
C vs. E

Enjoy. Here's the same solution in Perl from Jan Dubois and again in VBScript. Who wants to do the F# version and the Ruby version? What about just LINQ to Objects?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Six Months in the Inside - Am I evil yet?

March 3, '08 Comments [58] Posted in Microsoft | Musings
Sponsored By

imageYikes, I got an email from HR today that said "Congratulations on your 6th month anniversary at Microsoft!" Has it been that long? Apparently so, although it feels like maybe three months, tops.

I learned a lot about the culture in the first three weeks. There is a lot of groupthink and echo-chamber type behaviors from folks that have been there a long time, but most people I've interacted directly with are always re-asserting their independence and catching themselves thinking old-style thoughts, which is comforting to me.

It's one thing to exhibit an undesirable behavior, but it's much worse to be ignorant of that behavior. I think Microsoft's biggest problem right now is answers like "We've always done it that way," whether it's naming, versioning, documentation, conferences, whatever. I like to keep things a little more agile and tighten up the feedback loop. I think a process of continual improvement and self examination is so important.

What is my job?

I get this a lot. Seems like an obvious question. I took the title "Developer Division Community Liaison" because it was very broad. Phil likes to say I'm paid to be Scott Hanselman, but I don't like that very much because it implies some kind of punditry. If I ever start sounding Dvorak-esque, please let me know.

When my dad or the public (read: non-computer person) asks what my job is, I tell them "I'm writing a book that will never end (blog) and create training materials like videos and tutorials for Microsoft." When a technical person asks, I say the same thing with more detail. Also, if ScottGu coughs, I get him lozenges. Ahem. Yessir!

My boss runs http://www.asp.net, http://www.silverlight.net, http://www.windowsclient.net, etc, but our team is very small, only four FTE (Microsoft-speak for Full Time Employees). But, we're growing. At Microsoft we're graded on our ability to "meet our commitments" and my commitments (which were written up in a formal meeting) are mostly metrics like "write n number of significantly technical blog posts, write such-and-such book, give x number of presentations." Commitments are supposed to be a stretch, and I've got 7 different significant commitments so I've had some really late nights. The "liaison" portion of the job is also becoming more formalized in the next month, so I may take over some specific MVP-type groups.

This paragraph added for clarity (see comments): No, my job isn't to blog, although the blog is a good place to point to stuff I do. Folks originally wanted me to make a blog at msdn.com but I thought that was silly. For my day job, I do screencasts, tutorials, presentations, community outreach, books, articles for MSDN, internal presentations, advocate for the customer (this takes up more time than you'd think), provide direct feedback to the product groups, route your feedback (you know this if you've ever emailed me with a problem) and troubleshoot obscure bugs, as well as working on technical strategy with certain wonks at Microsoft. As I said in the Blue Badge post, the podcast is still belongs solely to Carl and me and I pick the guests with tips from the audience.

When I write, there's no editorialization, meaning that no-one reads my posts before I send them, although I often check with product groups to make sure I'm not completely wrong on some technical detail. Microsoft is pretty mellow and says "blog smart." That said, I'm sure I could get fired if I wrote something truly bogus, but otherwise there's no ghost writing. (Yes, ScottGu still writes his own posts...so far).

Sometimes ScottGu will email me with a one line note like this one yesterday about IIS7 and FTP7 "This might be a cool blog post to cover.  It has a ton of new features (including integration with membership/roles), new admin tool and a bunch of cool new features."

However, I already had FTP7 on my list of cool things since I've been talking to the IIS7 team and that'll hopefully be done today or tomorrow. It's funny we usually think about the same general things and I'm mostly either a day ahead or a day behind whatever cool thing is going on.

Am I Evil yet?

P0000259 I haven't been invited to any evil (or eeeveeel) meetings and haven't found the evil mailing list. As far as I can see Microsoft is less evil as it is unorganized. Within groups, communication is pretty good, but between divisions is trickier because there's always a doppleganger out there, like Evil Spock who is working on the same thing you're working on. I guess that means there's a Scott Hanselman out there without a goatee writing a similar post as this?

That pic is me in my early twenties. If Chins Could Kill...I'm trying to find a non-bearded pic but that's the best I can do! That guy doesn't look evil, right?

Working Remotely

0900aecd8054e6ca_null_null_null_10_09_06-2 The Remote Office thing is still lonely, but I'm making up for it with regular lunches and LOTS of video conferencing thanks to ooVoo. My master plan to make a robot out of a Roomba has fizzled due to lack of a battery (and my lack of a mechanical engineering degree) that could last a full day. My new "Plan B" is get a 42" LCD (as seen at right) and make a Portal into my house.

What have I done well?

I thought the first practice videos turned out well, and I have taken all the feedback you've given and applied it to a new four-part tutorial on MVC that will be coming soon, hopefully formalizing those best practices.

I think the Wiki (beta) is turning out pretty cool. I seeded it, but there's already contributors who have exceeded the number of posts I've added and greatly improved it.  I think there's a lot of work we can do to make the administration better for moderators, but it's looking nice regardless, so far.

I've had a lot of fun speaking lately. When I spoke while I was working at Corillian, I usually had to take vacation days or do it on the sly side, although for large conferences my boss at the time was exceedingly cool about it.

What have I done poorly?

I am not managing my time very well and since we've got a 3 month old and an enthusiastic 2 year old and I'm working from home I feel like days are very fragmented. It's good to be home, but my wife thinks I'm actually around less which is definitely a not good thing to feel. I need to do a better job of getting up earlier and banging out work. I like being informed, but I think I may need to go on an info-diet to find more time to get things done.

Have you started a new job in the last year? How is going for you?

Related Posts

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.