Microsoft veteran explains Windows quirk that made videos play in Paint

Raymond Chen says the OS used green-screen overlays to fake video playback – with curious side effects

Microsoft veteran Raymond Chen has answered a lingering Windows question – why did video screenshots keep playing in Paint?

In a post on Microsoft's Old New Thing blog, Chen explained that it's all about green screen technology and making the best of the limited resources available to the OS at the time.

Windows used a technique familiar to video production, chroma-keying. "The media player program didn't render the video pixels to the screen," he explained. Instead it rendered video pixels to a graphics surface shared with the graphics card and told the graphics card that whenever a green pixel was written to the screen, a video pixel from the shared graphics surface should be written instead.

"There are a few advantages to this approach," he explained.

First, the pixel format didn't need to be the same – you could specify that the shared graphics surface had a pixel format that matched the video, so no need for any pesky conversion. Second, the content could be updated without a full paint cycle, meaning video performance could remain brisk even if the rest of the user interface threads were crawling.

You could use two shared graphics surfaces and flip between them to avoid tearing and have the screen update at once for the entire frame.

However, things went awry when users took a screenshot from the media player and pasted it into Paint. Rather than the video frame, users would get whatever Windows had provided the graphics card to use for its overlay. "These special surfaces were called 'overlays'," said Chen, "because they appeared to overlay the desktop."

"Your screenshot was a screenshot of the desktop screen, and it contains green pixels where the video would go."

Opening the image in Paint meant Windows sent those green pixels to the graphics card. However, if the media player was still running and the overlay was active, those green pixels would get replaced by the pixels of the video.

"The video card doesn't know that the pixels came from Paint. Its job is to look for green pixels in a certain region of the screen and change them into the pixels from the shared surface."

If you moved the Paint window so it no longer overlapped the media player, the true nature of the bitmap was revealed: "It's just a bunch of green pixels."

These days, content is now rendered to a full desktop image before being sent to the monitor, and the compositing process that once caused video to play in odd places and green pixels turning up unexpectedly is a thing of the past.

It's something to remember when looking at a television presenter who has made some poor wardrobe choices and appears partially transparent. Windows could also have a few issues in the early days of desktop video. ®

More about

TIP US OFF

Send us news


Other stories you might like