6

I want to best render RadialGradientBrush in my wpf application. This is my XAML code:

<Grid>
    <Grid.Background>
        <RadialGradientBrush>
            <GradientStop Color="#FF3A3A3A" Offset="1"/>
            <GradientStop Color="#FF323232"/>
        </RadialGradientBrush>
    </Grid.Background>
</Grid>

This is WPF render:

WPF image

I change this in Photoshop render (check the Dither in gradient overly):

Photoshop image

ouflak
  • 2,458
  • 10
  • 44
  • 49
Ali Yousefi
  • 2,355
  • 2
  • 32
  • 47
  • 1
    You should upload the pictures to somewhere else. It seems SO is downsampling the images, so we don't see the problem. – Euphoric Dec 18 '14 at 08:15
  • Look at this: http://www.iceflowstudios.com/2013/tips/smooth-gradients-in-photoshop-dithering/ you can fix this in photoshop but i cannot fix this in wpf – Ali Yousefi Dec 18 '14 at 08:25
  • 1
    There is no dither setting in WPF, but +1 for an interesting question. – Sheridan Dec 18 '14 at 09:00
  • 1
    @Euphoric actually, if you look really closely you see the bands in the first image. The link provided helped because then I knew what to look for. – default Dec 18 '14 at 12:32
  • It's just not possible without dithering (WPF does not support dithering on their standard brushes). There is so much a 24-bit display can show: exactly 256 steps if you take a single component, or all three components must be the same (as in your example). If the gradient ocurs over a larger area than 256 pixels, banding will ocur and there's no standard workaround around this. You could do a shader using the GPU which does dithering, but that's far from being a general solution and it's not without its side effects. – Jcl Dec 18 '14 at 18:35
  • 1
    If you go the GPU route, this link might prove useful as a starting point: http://blogs.msdn.com/b/greg_schechter/archive/2008/05/12/a-series-on-gpu-based-effects-for-wpf.aspx (or directly using `ShaderEffect`: http://msdn.microsoft.com/en-us/library/system.windows.media.effects.shadereffect(v=vs.110).aspx) – Jcl Dec 18 '14 at 18:36

0 Answers0