Howto use OpacityMask and Images

I have an image with a white background. Please tell me if I can use the OpacityMask for that image to make the white background transparent.

This shows nothing:

<Image Canvas.Top="3" Source="images\Journals.png" x:Name="journals_Image" Width="32" Height="32">
<Image.OpacityMask>
<SolidColorBrush Color="White" Opacity="0" />
</Image.OpacityMask>
</Image>

Thanks,

Michael S. Scherotter

[537 byte] By [mscherotter] at [2007-12-31]
# 1

Hi Michael,

I do not believe you can use the OpacityMask property to apply to the background of your image. You could however open your image up within something like Paint.NET and make the white background transparent. WPF/E supports .png image files which support transparent items.

Chad

ChadCampbell at 2007-9-6 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...
# 2

An opacityMask takes the alpha channel of the brush object assigned to it and applies that to the containing object (the Image tag in your case). In your example above, the brush has opacity zero and therefore your image does not show.

You could apply an ImageBrush to the OpacityMask property of your Image, but that would not give you the behavior you are looking for: it would apply the alpha channel of ImageBrush.ImageSource to your original Image tag. There is currently no way of saying: apply any white pixels as the opacity mask to this other image.

Thanks,
Ed Maia
WPF/E Program Manager

EdMaiaMSFT at 2007-9-6 > top of Msdn Tech,Silverlight (formerly WPF/E),Silverlight (formerly WPF/E) Developer Issues...