Hi all,
as you see in previous brush there is lines in the middle,
it isn't so smooth
how to make it smooth? (how to remove that lines)
i create it with blend
<Grid x:Name="LayoutRoot">
<Grid.Background>
<LinearGradientBrush EndPoint="0.452,1.962" StartPoint="1.164,-0.352">
<GradientStop Color="#FF202020" Offset="0"/>
<GradientStop Color="#FF545454" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
</Grid>
The banding is an artefact of the gradient algorithm. It has to break the area in to bands each filled with a slightly different colour. The edges are in fact an optical illusion which has the effect of making them more visible than you would think. To reduce this effect you need to reduce the width of each band.
The solutions are:
I do realise that these solutions are either a) not possible or b) not practical. This is a problem you are going to have to live with.
One practical solution might be to replace the brush with an image created in Photoshop or other image processing package. This might give you an image with less banding - but then you are restricted to the size of the image - you can't grow it without pixelation.
A cheap and dirty option from another answer of mine is this:
Add the gradient to a container, give it a small negative margin so it spills over a little, add a BlurEffect to the gradient, and then turn on ClipToBounds on the parent container. This way the gradient evens out a bit nicer at the expense of performance.
Depending on your use case, this may not be viable, however.
Example:
The negative gradient should be equal to the blur radius so that it doesn't become transparent on the edges.
Some time ago I wrote smooth linear gradient for my WPF project. It removes the banding, but there are two caveats:
{DynamicResource}
.It is implemented as dynamicly created
ImageBrush
, using Ordered Dithering. Additionaly, it is also aMarkupExtension
, as one cannot simply inherit anyBrush
class (the're all sealed).Usage in resource dictionary:
and then in control style: