IanG on Tap

Ian Griffiths in Weblog Form (RSS 2.0)

Blog Navigation

April (2018)

(1 item)

August (2014)

(1 item)

July (2014)

(5 items)

April (2014)

(1 item)

March (2014)

(1 item)

January (2014)

(2 items)

November (2013)

(2 items)

July (2013)

(4 items)

April (2013)

(1 item)

February (2013)

(6 items)

September (2011)

(2 items)

November (2010)

(4 items)

September (2010)

(1 item)

August (2010)

(4 items)

July (2010)

(2 items)

September (2009)

(1 item)

June (2009)

(1 item)

April (2009)

(1 item)

November (2008)

(1 item)

October (2008)

(1 item)

September (2008)

(1 item)

July (2008)

(1 item)

June (2008)

(1 item)

May (2008)

(2 items)

April (2008)

(2 items)

March (2008)

(5 items)

January (2008)

(3 items)

December (2007)

(1 item)

November (2007)

(1 item)

October (2007)

(1 item)

September (2007)

(3 items)

August (2007)

(1 item)

July (2007)

(1 item)

June (2007)

(2 items)

May (2007)

(8 items)

April (2007)

(2 items)

March (2007)

(7 items)

February (2007)

(2 items)

January (2007)

(2 items)

November (2006)

(1 item)

October (2006)

(2 items)

September (2006)

(1 item)

June (2006)

(2 items)

May (2006)

(4 items)

April (2006)

(1 item)

March (2006)

(5 items)

January (2006)

(1 item)

December (2005)

(3 items)

November (2005)

(2 items)

October (2005)

(2 items)

September (2005)

(8 items)

August (2005)

(7 items)

June (2005)

(3 items)

May (2005)

(7 items)

April (2005)

(6 items)

March (2005)

(1 item)

February (2005)

(2 items)

January (2005)

(5 items)

December (2004)

(5 items)

November (2004)

(7 items)

October (2004)

(3 items)

September (2004)

(7 items)

August (2004)

(16 items)

July (2004)

(10 items)

June (2004)

(27 items)

May (2004)

(15 items)

April (2004)

(15 items)

March (2004)

(13 items)

February (2004)

(16 items)

January (2004)

(15 items)

Blog Home

RSS 2.0

Writing

Programming C# 5.0

Programming WPF

Other Sites

Interact Software

Avalon ImageEffects and Vector Graphics

Saturday 17 January, 2004, 03:55 PM

Avalon can apply a variety of effects to images before displaying them. They support a useful range of common bitmap effects such as blur, sharpen, tinting, and conversion to greyscale. One I particularly like is ImageEffectGlow - this applies a glowing halo to the bitmap of your choice. This provides you with a subtle way of drawing attention to a UI feature: you can make it light up, rather than having to do something as crass and obvious as changing its colour or making it blink.

Robert Wlodarczyk, has written a couple of blog entries on Avalon image effects recently. The first shows the standard image processing type effects, and the second shows the ImageEffectGlow. (It uses a slightly strange combination of colours though, so it doesn't look like the image is 'glowing' as such. But that's hard to achieve when the background is already white - how do you make something look like it's lighting up when it has been drawn on a background that is already as bright as possible? Fortunately he has generously provided the source, so you can mess about with it. It will look a little more glow-like on a dark background.)

But I Want More!

Much as I like these examples, there is a potential use for image effects which these articles don't address.

When I discovered the ImageEffectGlow class, the very first thing I tried to do was apply it to a fragment of XAML to see what it would look like. Unfortunately, it turns out you can't do that in the PDC Longhorn build... All of Robert's examples show the effects being applied to bitmaps rather than markup. (His example programs are written in XAML, but the only things he applies the effects to are bitmaps.) And that's all the current build supports.

Now you might leap to the conclusion that I simply don't understand the distinction between vector graphics and bitmaps, because if I did, I wouldn't be trying to apply image processing effects to vector-based markup. However, it's not really such an unreasonable thing to want to do - vector graphics have to be rasterized at some point in order to make them appear on screen. (I'm fairly sure that Windows doesn't support vector graphics displays...) So it's technically entirely possible to apply a bitmap effect to a chunk of vector-based markup. The markup rendering system simply has to apply the effect after it has rasterized graphics but before it puts it on the screen.

SVG lets you do this with its filter effects support, so I thought it was likely to be possible in XAML too. But after much experimentation, I couldn't find a way of doing it. Not only can you not apply a filter to a block of markup, there doesn't even seem to be a way of telling Avalon to render your markup into a bitmap so you can mess with it.

At the PDC, there was a talk on the Avalon rendering pipeline. (I think it was one of Greg Schechter's talks, but I could be wrong.) The talk also discussed one of the features that will be added in later versions. In a future build, Microsoft are planning to add a facility that lets you take animated XAML and generate streams of images at the frame rate of your choosing. (You would then most likely feed these into a video codec of some kind to generate a compressed video stream.) This seemed to be a solution to my "How do I convert markup into a bitmap so I can start applying effects to it?" problem, albeit a slightly over engineered one: I only want one frame, not an entire video sequence! So in the Q&A session, I asked if this was the way to apply an ImageEffect to a piece of XAML.

I was delighted by the answer. I was told that although this would certainly work, the plan is to support the application of image effects to markup directly. So in some future build, Avalon will happily do the work for us - we won't need to render stuff into some bitmap and then apply the ImageEffect(s) of our choosing. We will just be able to apply effects to markup like you can today in SVG.

Yay!

Copyright © 2002-2024, Interact Software Ltd. Content by Ian Griffiths. Please direct all Web site inquiries to webmaster@interact-sw.co.uk