Wednesday, 27 August 2008

Say Goodbye to Laser... whats to come?

Now I remember when I got my first Optical Mouse, and the difference between that an the conventional ball mouse was incredible, afterwards the jump from Optical to Laser was another progressive step towards mouse nivana... however now Microsoft is at it again with a teaser just saying 'Say Goodbye to laser' with a date. Now I can't wait to see what technology they have thought of, should be interesting to say the least.

Tuesday, 26 August 2008

Photosynth Test - My Kona Stinky

Well as I said I would test out Photosynth and so today I spent some time taking some pictures of my bike and then uploaded them to Photosynth, so if you want to see it in action then follow this link.

Photosynth has been released

Photosynth, the 3d Imaging tool by Microsoft Live Labs has now came out of its technical preview and is available to all, so go try it out and create your own synths as they call them. Expect to see a synth of my shiny new Kona soon...

Thursday, 14 August 2008

Visual Studio 2008 SP1

Well we all have been waiting a long time for it and finally it is here; Visual Studio 2008 SP1. With many improvements and some new features it seems to be more than just a service pack but an evolution to your coding experience.

Some of the big improvements I should mention are those around the .Net framework and how WPF applications see a significant performance increase (~30%!!) Also the footprint for some applications will be reduced with the introduction of Profiles that will remove any excess .Net functionality that isn't needed.

Finally WPF will also see the introduction of a web browser control however it is handle based from a standard browser control and thus doesn't yet support some of the WPF goodies... how cool would it be to do 3D transformations to a webpage!

Monday, 11 August 2008

New Bike!

Well today I purchased my shiny new bike (though have to wait 2 weeks till I can use it, seeing as I'm in York for most of the time till then). Its a 2008 Kona Stinky and its awesome, though now I have no money.

Friday, 8 August 2008

Apple's working culture

Working at Microsoft I have to say that it is one of the nicest working experiences I have ever had, so it made me laugh when I read about Apple effectively creating a slave labour culture amongst its employees. What Apple's been doing has been reclassifying some of its technical employee's so they don't have to pay them extra or even give them even a meal allowance. Hmm... has slave labour gone into making your pretty iPhone?

Thursday, 7 August 2008

Wubi Wooes on Hardy Heron for my Macbook

I like to try out new things on my Macbook, its my test machine really. My main PC happily runs Server 2008 and does everything I need it too however I like to have fun on my Macbook. To start off with Its running OSX 10 and Vista via Bootcamp, although I shall install Server 2008 next time on it, but I wanted to try out Ubuntu on it as well because it doesn't work on my main pc due to the RAID configuration. (It runs and hides when it notices the six hdd's but I think it just doesn't recognise the chipset; which to be honest Vista didn't as well)

So I installed Hardy Heron via Wubi (though wanted to try the new 8.10 version but it complained when installing), however as the bane of most of my Ubuntu and Linux experiences; the wireless doesn't work. Annoyingly Apple changed the provider of their wireless chipsets to Broadcom which doesn't at all help the Linux community. I tried compiling some drivers, using Ndiswrapper and some other tools but still no success. Overall the experience was good but back to Vista till this problem is fixed.

Sunday, 3 August 2008

My Pictures 3D Helix using WPF (Part 1 of 3)

Now everyone enjoys looking at pictures and reminiscing over good times; myself included however when browsing through My Pictures I thought there has to be a better and more interactive way to do this. This occurred quite luckily around the same time I’ve been working on a project using the 3D abilities of WPF, and so it occurred to me; a 3D method of viewing your images while also discussing what it’s like to develop software at Microsoft. So now, let’s get stuck in and make something amazing...

So first of all I should mention that I’ll be using the combination of C# and WPF to create this application, if you’ve never coded in C# then now is a good time to learn and I’ll try my best to make what I do as easy to understand as possible. Therefore, head over to and grab yourself a copy of Visual C# Express Edition that is entirely free to use.

Now the first thing you will need to do is create a new WPF application that we can build from; for this project I called it StudentZine_Helix, you will instantly notice that building a WPF application is quite different from the old WinForms method of building an application. Firstly there is something called Xaml which you can use to construct the user interface and possibly the entire application however for this project we will still mainly need to stick with code.

When we write code here at good old Microsoft, we tend to have an end goal in mind, a set of requirements and repeated testing to eliminate bugs... so quite different to thinking ‘I want to make something shiny’ and writing the code for the final app of this series over my lunch break. Normally we also work in teams so we can gain feedback and reflect off the skills and resources of others.

When you first make a WPF application you will be greeted by the xaml editor and design view, to start off with its a boring white window so let’s make it larger and also a different colour. To do this we need to alter the xaml attributes for the windows Title, Height, Width and add the Background property, the attribute properties I used were the following:

Don’t worry if you need to make the window smaller, everything scales nicely.
In order to view all the images in the My Pictures folder we will first need to get a list of all the files. We can do this by using DirectoryInfo to return a list of all the files in the folder; however, we’ll then need to strip away all the ones that are not valid image types, thus leaving us with a usable list of filenames.
So now, go into the C# code view and at the top of the code declare the namespace:

Then in the window’s class, declare a list of strings that will represent the image file extensions we will allow to be loaded in the application:

I have already populated with three of the most common image formats to use however, you can add or remove them depending on what you want. Now at the same time declare another list of strings for the final list of filenames:

In the code for the function to retrieve the filenames we firstly use DirectoryInfo to get information about the directory from which we can extract the list of files, we use System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures) to return the path of the My Pictures folder as it always returns the path of the current user. Using the .GetFiles("*", SearchOption.AllDirectories); method we can return all the files in the directory as all subdirectories; kindly meaning we don’t have to implement a search algorithm ourselves. Finally, we go through each FileInfo and store only the filenames of the correct extension. Below is the source code for the implemented function.

For the moment, let’s just render the first image in the filelist to the screen with a nice border so you can see the code in action.

To make the border and the image we need to add a few UIElement’s to the Grid control that’s declared by default in the xaml file, go back into the xaml file and between the Grid declarations paste the following code:

The first part declares a border control, we give it a margin around it of 20 pixels on each side and the border itself is white and 10 pixels on each side. We set the vertical and horizontal alignment to center so it automatically resizes depending on the size of the picture. Finally we set the Opacity of the border to 0 so it’s transparent to begin with so we can add a cool fade in effect later. Inside the border, we declare an image but we don’t set the source image just yet.
Now back to the C#, we have to create a function to load an image and display it onto the image control we just created, it may seem a bit lacking at the moment but we’ll add to it in a bit.

To wrap this all together by calling these functions when the application loads, so in the class constructor place after InitializeComponent() place the following code.
Now when you run the program you will see... nothing, that’s because the border we declared earlier has an opacity of 0 so we can’t see it. Guess we should add in a fade in effect.
To use animations in WPF you’ll first have to add the following namespace to the project:

We can implement the animation in either xaml or in the code but for this article I’ll show you how to implement it in code. So going back to the last function you just wrote add the following code to the end of it.
So now, finally when you run the application you will see it nicely fade in an image.

The observant of you may notice that’s not 3D or a helix; this week we were laying the groundwork so tune in next time for when I’ll show you how to do 3D effects in WPF.

Friday, 1 August 2008

StudentZine Article Coming Soon...

This months StudentZine Article will be about how to create a 3D Helix of your My Pictures folder, trust me it looks awesome. Till then check out the StudentZine Blog

Increasing WPF rendering performance

Please Note:
This article has been updated and can be found on my new Blog at


Lately I have been coding a lot using WPF and one of the main area's I've been involved in is the 3D rendering, however its easy to find out that there are quite a lot of performance hits across the board when it comes to WPF.

One of the biggest hits is the way it renders, normally WPF will try to do as much as possible using Hardware Graphics Acceleration however certain functionality will cause it to fall back to software based Rasterizing; such as certain BitmapEffects. So I guess there is to limit yourself to features that are fully hardware assisted.

So once everything is using the hardware there still can be slowdowns and stutters caused elsewhere in your program, one of the big issues I've had lately is how WPF handles ImageBrush, when loading an image it will load the entire image which if your rendering a 10mp digital photo can cause a huge slowdown if you're using multiple instances of different brushes. There are a few tricks to start off with, firstly by altering the RenderOptions of the ImageBrush to increase its performance. Below is a sample of code that alters the RenderOptions of the brush _PictureBrush.

RenderOptions.SetCachingHint(_PictureBrush, CachingHint.Cache);
RenderOptions.SetBitmapScalingMode(_PictureBrush, BitmapScalingMode.LowQuality);

However this may not be enough as the pictures are still being loaded into memory, therefore to reduce their footprint, what we want instead to do is to produce and use instead a thumbnail of the original image.

public BitmapImage CreateThumbnail(Uri Source, int PreferredWidth)
BitmapImage bi = new BitmapImage();
bi.DecodePixelWidth = PreferredWidth;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.UriSource = Source;
return bi;

This code takes a Uri Source and creates a thumbnail of the PeferredWidth, thus if you use this method you can drastically reduce the memory requirements of handling images as Brushes.