Greyscale Bitmap Effect for WPF
March 21st, 2008 | by rob |Technorati Tags: WPF,Greyscale,BitmapEffect
[ please see the THIS post about single assembly effects ]
Whilst trawling the MSDN forums looking for a solution to a problem i was having (completely unrelated to bitmap effects - i’m easily distracted
Once the component is registered , create a reference to the managed Dll by adding it to your .NET project.
Next, create a namespace in your XAML for referencing the new effect :
xmlns:Greyscale=”clr-namespace:Greyscale;assembly=GreyscaleBitmapEffect”
now you have the namespace defined you can add the bitmap effect straight into your code like so :
<Window x:Class=”GreyscaleEffectTest.Window1″ xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
Title=”GreyscaleEffectTest” Height=”400″ Width=”400″
xmlns:Greyscale=”clr-namespace:Greyscale;assembly=GreyscaleBitmapEffect”>
<StackPanel>
<Image Name=”flower” Source=”BOUQUET BIG_YELLOW.png”>
<Image.BitmapEffect>
<Greyscale:GreyscaleBitmapEffect />
</Image.BitmapEffect>
</Image>
</StackPanel>
</Window>
if all has gone to plan, the effect shows immediately in devstudios design window.
If you’re using blend, load up the project (after you’ve added the references) and go to the properties window.
After you’ve selected a visual element to add a bitmap effect to, click the expander under the appearance panel to access the bitmap effects
Click on the New button and you should then see the dialog which allows you to select the Greyscale effect from the assembly that your project references
select the GreyscaleBitmapeffect, and click ok
Depending on your items you should see the following sort of result
before :
After
For my next trick, I’ll be writing a HSLBitmalEffect, where the all three elements will be exposed as dependency properties, so you can animate the saturation from 1.0 to 0, giving the same sort of effect as the Windows Shutdown , where the screen fades out. You can almost do this with the GreyscaleBitmapEffect above by triggering the effect when your application loses focus, and greying the entire window. No animation but almost as effective. Watch this space for the HSL version coming shortly!
Enjoy!
Download the .NET Assembly
and
Technorati Tags: WPF,Greyscale,Grayscale,disabled look
7 Responses to “Greyscale Bitmap Effect for WPF”
By Micche on Mar 26, 2008 | Reply
Good work! but the download links aren’t valid!
thanks
By rob on Mar 26, 2008 | Reply
Hi Micche!
Thanks for taking the time to comment!
I’m having a bit of a problem with Live! writer at the moment, it won’t upload files or pictures to my Wordpress blog, I’m looking into it now. As an aside, you might want to watch out for the next couple of posts, they feature a registration-less version of the greyscale effect , and a full HSL effect too, although this isn’t too fast at the moment. I’m looking into modifying the HSL version to use DX9+ pixel shaders to bring up the speed for whole screen effects.
If you’re desperate for the greyscale effect DLL’s i can mail them to you no problem.
cheers,
Rob
By James on Oct 28, 2008 | Reply
Seems like your link is broken
By edda on Feb 25, 2009 | Reply
Is there a copyright problem to use your DLLs in our projects?
Thanks.
By rob on Feb 25, 2009 | Reply
Hi Edda,
No there are copyright problems, these examples and the associated code are effectively free to use, but not resell. However I’ve done a full set of more professional WPF effects that I fully support and have for sale over at http://www.bitmapeffects.com.
£29.99 buys you the effects + integration support and any new updates for 12 months. There’s no way to currenlty pay for the licence on the site (yet) but if you wanted to purchase the bitmap effects drop me a mail and I’ll send you paypal details.
cheers,
Rob
By Tracy on Sep 21, 2009 | Reply
I’d like to try this out… I see the download link is not valid. Could you let me know the correct location for the source/assemblies?
Regards,
Tracy
By Maxxi on Sep 22, 2009 | Reply
The link is down, can you please fix it?