Reputation: 548
I'm experiencing some trouble with the combination of an OpacityMask and Adorners in WPF.
Basically there is an image with an opacity mask applied to it and above it an adorner, which is a moveable guideline.
When the Adorner is moved, there are artifacts in the image. Along the bounding box of the adorner, there are 1px wide lines appearing. At these lines, the image is getting transparent (although the area is not made transparent by the opacity mask). This behavior is depending on two (afaik) factors:
Any idea what could cause this behavior or how I could avoid it?
Here is some XAML-Code representing my layout. This is not the actual layout code. I've tried to reduce the layout content to the key components, which I think are involved with the problem.
<ScrollViewer>
<ContentControl> <!-- control for zooming the content with a render transform -->
<Image Source="..." /> <!-- Background-Image -->
<Image Source="..."> <!-- Foreground-Image with Mask -->
<Image.OpacityMask>
<VisualBrush />
</Image.OpacityMask>
</Image>
</ContentControl>
<AdornerLayer>
<myControls:GuideLineAdorner />
</AdornerLayer>
</ScrollViewer>
A Screenshot of the artifact lines:
Upvotes: 1
Views: 441
Reputation: 143
I recently ran into exactly this issue. After a little googling, I ran into this msdn forum post that gave me the workaround I needed.
In my case, I had a Grid with an OpacityMask. The children of the Grid were displaying the artifacts. To prevent the artifacts from displaying, I was able to set the RenderOptions.EdgeMode attached property to 'Aliased' on my grid.
Upvotes: 1