Welcome to shell: revealed Sign in | Join | Help
in Search

Shell Blog

The Background on Backgrounds

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!

 

Published Saturday, October 28, 2006 12:58 AM by davevr

Comments

 

Views on Vista said:

Talk about last minute, but the guys over on the Shell Team managed to get the problem with setting background

October 28, 2006 1:47 AM
 

wwahammy said:

While I can't say this will really affect me, I'm glad you guys have come up with a solution but I really hope this is better addressed in a service pack or next Windows version. There should be a standard way of doing this. Have a "photograph" mode where it does the scaling like in Explorer and Photo Gallery leave available the ablity to set whether you'd like your background in the older mode (with tiling, stretching etc.). Maybe use a radio button on the background control panel to switch between the two modes? Or have Windows guess on the proper mode based on the size of the image? (Images over say 640x480 in photograph mode and images under that tiled or something)

October 28, 2006 2:30 AM
 

millenomi said:

And, God, take out stretching from the algorithm. It kills otherwise very good images. Scale up and crop is MUCH better on the eyes.

October 28, 2006 5:51 AM
 

Dugbug said:

Look folks, this is exactly why people harp on your inconsistencies all the time.  WHY did the explorer EVER use different imaging routines in the first place?  Better be glad you don't have me as a supervisor.

You guys need to break out what code is where and pool your infrastructure code together.  Just unbelievable.

-d

October 28, 2006 9:44 AM
 

dr_evil said:

I have 3 screens, monitor #2 all to the left, monitor #1 in the middle and monitor 3 to the right. When I choose a background image with a size of 3840x1024 (the resolution of my three displays), Vista displays the upper left corner of the image on the upper left corner on monitor #1. Instead of monitor #2.

That makes it impossible for me to chose a wallpaper which is larger than 1280x1024. Is that bug fixed in RTM?

October 28, 2006 12:19 PM
 

davevr said:

We are rethinking the whole way we approach desktop backgrounds for the future.  The current "stretch or tile a picture" is something from Windows 3.1.  I will let the people responsible for this actually chime in with any specific plans, but things like proper photo handling and better multiple monitor support are must-haves.

That said - the purpose of the desktop backgrounds is to have a place in the UI for personalization and/or branding that does not impact the usability of the system.  Backgrounds in general are not a great way of doing this.  What is the point of putting your favorite picture there when it is covered by windows 98% of the time?  We are experimenting in the UI with different ways of including such "aesethic moments" that are better at presenting such content.

October 28, 2006 1:07 PM
 

hitmouse said:

Some parts of Vista allowed you to specify a GIF or a PNG as wallpaper, while other pieces wouldn't allow it. Is that all resolved now?  (Control Panel vs Photo Gallery vs Paint vs ... )

October 28, 2006 2:23 PM
 

faramond said:

Tiling a picture might be from Windows 3.1, but it still can give nice results. Check out:

http://www.k10k.net/pages/pixelpatterns/

Those images are much smaller than even a small photo (at a few hundred bytes total!)--so VERY high performance--and they look classy.

It would be nice if Windows shipped with some patterns of this ilk.

October 28, 2006 6:13 PM
 

Runt888 said:

Am I the only one who finds this a little bit scary?  Microsoft, the company that writes the OS that the majority of the PCs in the world run on, has this much trouble with using JPEGs as a background image?  Being a software engineer myself, sometimes I wonder what the heck is going on over in Redmond.

I definately agree with DugBug - make one API to deal with background images, and force everyone to use it.  Then adding additional capabilites like using JPEG images would be easy.

October 29, 2006 5:58 PM
 

someone said:

THANK YOU SO MUCH! NOW maybe we can expect 32-bit PNGs with alpha transparency natively supported as wallpaper in Vista SP1 ;  )

October 29, 2006 9:49 PM
 

Gofromiel said:

This is absolutely ridiculous !

I come from an OS where images are "abstract" concept. They are no "PNG", "JPEG" or f*cking "BMP", they are just images. They are all opened and handled with the same API and methods (OOP), no matter their type. They can be scaled and cropped in every possible ways. They can be positionned everywhere just like CSS does with it's "background" property. Further more, "new" types of image can be handled easily by adding a "translator" to the datatype system. For example the "gradient" type is one of my favorite.

This OS is not Linux, it's not OSX, it's not BeOS... it's AmigaOS 3.1 from 1993 !!!

WAKE UP GUYS !!!

If you need some code, just ask me :-D

October 30, 2006 3:08 AM
 

kiwiblue said:

Sic transit gloria mundi... Microsoft - once the most powerful software company in the world - thinks that proper JPG scaling is a feat of engineering.

Sorry, couldn't resist :)

October 30, 2006 4:22 AM
 

shahine.com/omar/ said:

October 30, 2006 7:33 PM
 

atesti said:

I think there is something very important missing in the article: Active Desktop!

I don't recall correctly, but I think that setting a JPG in control panel in XP gives you a well scaled background JPG, although it is drawn using Internet Explorer codepaths. I remember that a bmp background and also going to deeper settings dialog resulted in black background for the icon texts, while a jpg drawn using active desktop technology resulted in transparent icon texts

Is that correct? Did you remove Active Desktop in Vista?

November 9, 2006 11:51 AM
 

Dominique said:

What you mean is the bug in the active desktop that does a very blocky scaling of jpeg's when you enable active desktop by putting a website on the desktop and indeed the text if icons is not transparent anymore. The blocky rescaling doesn't affect bmp's however although bmp's also have no transparent icon text. At the introduction of this article, it was mentionned that it's a new feature to be able to add jpegs as background.

Doesn't this feature already exist in Windows XP ? I can set a jpeg background without problems. You can even do it in Windows 98 although this enables active desktop and the pc will take about 20 seconds longer to start (VirtualPC is great to run those older OS'es, for old time's sake ;-)

January 23, 2007 4:02 PM
 

snsh said:

I don't understand why the author would prefer JPG wallpapaer to BMP.  For performance, I've always gone the BMP route rather than JPG.  This is especially true on Win2000 machines, where Active Desktop must be enabled to have a JPG wallpaper.  Active Desktop slows down everything, and creates the need for frequent explorer restarts, just to resolve simple Javascript hangups.  Autocomplete stopped working on gmail?  don't just close the browser.  reboot to restart Active Desktop.

And it seems to me that once an image is displayed on a computer monitor, it's a bitmap anyway.  So how is JPG supposed to help?  A compressed JPG becomes an uncompressed bitmap as soon as it becomes rendered in video memory.  So is there really a performance advantage to JPG?  It depends on how DirectX swaps things, but my guess is that better performance comes from BMP.  JPG sacrifices performance just to save a couple megabytes of disk space and a few milliseconds disk access.

February 14, 2007 1:48 PM
 

sshrum said:

Ack...you guys ditched Active Desktop support in Vista so I had to jimmy-rig a small util I call Vistas (for Vista).

Allows me to define individual images for each monitor or (what I like to do) take a panoramic image and stretch it across all monitors.  Basically, I'm creating windows OVER the shell desktop (so I lose the shortcuts on the desktop...not a big deal for me as I disable that feature anyways).

Still just a band-aid over the lack of multi-monitor support for backgrounds.

I'll have a binary, writeup, and source (written in AutoIT) posted shortly at http://www.shrum.net/code/vistas but for now, it's a personal project until you guys update the desktop control panel to allow for this.

P.S.  Speaking of things missing for multi-monitor support: Take a look at my Relocate project (http://www.shrum.net/code/relocate).  Allows for repositioning / moving windows to other monitors using keyboard shortcuts. Why MS didn't include this functionality in Windows is beyond me.  :-)

March 6, 2007 4:37 PM
 

Prasanna Vignesh said:

Vista Tips and Tricks

September 12, 2007 12:30 AM
Anonymous comments are disabled

About davevr

I work for Microsoft, where I am a Research Manager for Windows User Experience Compliance team. I started at Microsoft in 1996 as a user interface researcher working in the Social Computing Group of Microsoft Research. Later I spent two years in Beijing, where I worked for Microsoft Research Asia and founded the Asia Center for Interaction Design. Prior to Microsoft I was VP of Technology for ImaginEngine (a children's software company). Before that, I spent 5 1/2 years in research at Apple Computer, where I worked on the SK8 project and in the Human Interface Group in ATG. In early life, I programmed Atari 800 games. My first computer was a Bell Labs CARDIAC. I still have one!
Powered by Community Server, by Telligent Systems © 2006 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement.