There has been a lot of attention in the last few weeks about the discrepancy in the desktop background appearance between the control panel and Windows Photo Gallery. This is something that we have been tracking internally for quite a while, so I thought I would clue in everyone on the issue here and how we are addressing it for RTM.
Various Approaches
There are actually several places in the user interface where you can set your desktop background.
The first is the desktop background control panel. The control panel lets you choose a BMP or JPEG image for the background, and also lets you choose how the image will be positioned on the screen. A lot of these options are meant to support using small images as desktop backgrounds, and aren’t really relevant for people setting their background to a full-screen photograph. Three position types are supported:
- Fit to Screen – the image is scaled to be the same size of the screen. If the image is a different aspect ratio than the screen, the image will be squashed or stretched to fit.
- Tile – the image is repeated at its native resolution as many times as needed to cover the monitor. So, if your image is 160x120 and your screen is 1600x1200, you will get ten copies of the image across and 10 down.
- Center – the image is displayed at its native resolution in the center of the screen. If the image is larger than the screen, it will crop. If it is smaller than the screen, the extra area will be filled in with the background color.
The second way is to right-click on an image in the explorer or Photo Gallery and choose “Set as Desktop Background”. This will do a good job of scaling the picture proportionally to fit the screen, making it bigger or smaller if need be. Rather than squashing or stretching it, it will preserve the aspect ratio, including cropping the picture slightly or adding a border.
The third way is from IE. You can find an image on the Internet, right click on it, and choose “Set as Background”. The image will use whatever position type is currently set in the control panel, fitting, tiling, or centering as appropriate.
The Dirty Details
Although these look similar, they are in fact not the same. The control panel applet works by directly setting a JPEG or BMP image. The Photo Gallery/Explorer approach works by making a new JPEG image that is pre-scaled to be the size of your monitor. And IE makes a new BMP the size of the source image. So why does this matter?
Well - support for JPEG wallpapers is a new feature in Vista. In previous versions of Windows, only BMP images could be used for wallpapers. Using JPEGs for wallpapers is a great improvement. A full-screen BMP image is several megabytes, and can even affect other performance enhancements like SuperFetch. JPEGs, being compressed, are much smaller.
But there is a problem with what could be pure JPEG goodness: the low-level code that draws the wallpapers was using a simple linear interpolation algorithm to scale them. This meant that JPEG wallpaper images that were not the exact resolution of your display would have noticeable scaling artifacts. This was a regression from XP, because XP always used BMPs. Even worse, users would only notice this problem when using the new control panel for setting the background. If they used the explorer or Windows Photo Gallery, a new pre-scaled JPEG would be created using a high-quality scaling algorithm, and that image would be rendered unscaled by the desktop code. And if the user set the desktop from IE, IE would create a Bitmap, which would scale properly just like in XP.

This image shows the difference: the nice scaling in explorer & photo gallery is on the left, while the linear scaling used by the control panel is on the right.
Can you say “major embarrassment”?
Possible Work-arounds
When we uncovered this issue, there were a few work-arounds proposed. This was originally not considered a hugely serious issue because the user could easily set their custom wallpaper using the explorer or Windows Photo Gallery. There was a lot of concern that the default wallpapers wouldn’t look great, and it really sucked that the “set desktop background” control panel would not be the preferred way for users to set backgrounds, but even with that we weren’t really thinking of this as a “recall windows” type of bug. But as more and more user feedback came in, we realized we had to do something.
One was to try to just use the Explorer approach from the control panel. Unfortunately this would have been too risky, not compatible, and too much of a hack. The explorer approach also had some other disadvantages. It didn’t support the various positioning options that the control panel does. Also, this approach will always create a big JPEG even if your original image was small, so it wasn’t suitable for customers who care about that sort of performance impact – and there are millions of them. Also – Explorer does not automatically rescale the wallpaper it makes when you change the screen resolution. For example, if your video driver is not in the box, then Vista will start at a lower resolution and then switch to a higher resolution after it downloads your driver. Then your bitmap will look bad again. (The control panel on the other hand will resample the image with each resolution change.)
We also tried changing the size of the default wallpaper to something that would look good when scaled using the linear scaling. But that didn’t produce great results, and wouldn’t have done anything for users or OEMs or anyone else setting wallpaper using the control panel.
For a brief time we even considered changing the default wallpapers to something that didn’t make the problem so noticeable. But as you can imagine it takes a really long time to come up with images that Windows can ship to everyone on earth without any legal or geopolitical issues. That was rejected almost immediately as impractical, not to mention lame.
We even thought of converting all of the in-box wallpapers back to BMPs. But that would ruin our perf gains, and again would only help us and no one else.
The Fix
With the end of Vista rapidly approaching and more and more attention on this issue coming from outside Microsoft, the dev team was working around the clock to come up with a feasible solution.
At this point in time, any solution had to have zero risk, which means it would need to have already been through rigorous testing. Creating a new scaler – even copying an existing scaler from somewhere else – would never be tested in time. They determined that there was a high-quality scaling algorithm that was available in the low-level code, on a code path that was already used for scaling BMPs. Unfortunately it only worked for 24 bit images, while the JPEGs were decoded as 32 bit images like PNGs and other compressed images. The 32 bit images, like icons, are not filtered when scaled.
Some smart dev determined that the only thing blocking the higher quality scaling was a source format of 32-bit. Since JPEG images are decoded as either 24-bit color or 8-bit grayscale, we can safely process them as 24-bit images and get the higher quality scaling! A solution was in our grasp. It was still looking bad for a while, where several attempts to take advantage of this caused major problems with icons and other graphics in the system. Eventually they managed to figure out a place that was confined to just the wallpaper setting code path where they could add just a few lines to try to convert the JPEG to 24 bit.
Then it was off to testing, where a battery of testers made sure that the fix still worked with wallpapers of all sizes and formats, at different DPIs, with and without DWM, on 32-bit and 64 bit versions of Windows, at different screen depths, with malformed JPEGs, and with & without Terminal Services running. Senior architects reviewed the code to comment on its risk, correctness, security impact, application compatibility, etc.
The Checkin
Once all of that was done and everyone gave their thumbs-up, it was time to head to central shiproom for the bug approval. The easiest way to explain shiproom is that you are going to court, with 20 or so judges representing different aspects of Windows, all of whom have the job of rejecting your change. They grilled us up and down about the risk of the change and whether it was worth taking a change for a purely cosmetic problem so close to ship. We tried to convince them that the fix was safe, it wouldn’t reset the testing on the whole product, and would be goodness for customers and OEMs everywhere.
In the end they agreed, and it was checked in on Wednesday. And there was much rejoicing.
Summary
When Vista goes out, you can have the best of both worlds – high performance JPEGs and proper scaling. Remember that using Windows Photo Gallery is still a good way to set wallpapers if you want to take advantage of their cropping and scaling options and you remember to re-do it if you change resolutions.
And I personally want to thank all of the beta users who drove attention to this problem, and all of the devs and testers who put in the effort to track this down and fix it. Thanks guys!