October 16, 2007

Grayscale an image programatically

This code allows you to dinamically apply a grayscale filter to an image contained in a div:

You have to either set the div and img height and width or set its position to absolute, or the effect won't work.
This seems not to work in ASP .NET pages, although it works perfectly on plain HTML.

There are more filters that you can use like the above, here's a list: http://msdn2.microsoft.com/en-us/library/ms532853.aspx

No comments: