Wednesday, 27 August 2008
Say Goodbye to Laser... whats to come?
Tuesday, 26 August 2008
Photosynth Test - My Kona Stinky
Photosynth has been released
Thursday, 14 August 2008
Visual Studio 2008 SP1
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!
Friday, 8 August 2008
Apple's working culture
Thursday, 7 August 2008
Wubi Wooes on Hardy Heron for my Macbook
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 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:
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.
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 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.
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...
Increasing WPF rendering performance
This article has been updated and can be found on my new Blog at MrPfister.com
----
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.BeginInit();
bi.DecodePixelWidth = PreferredWidth;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.UriSource = Source;
bi.EndInit();
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.