.NET Framework 4 in WPF not showing raster effect

I have a problem with VS2010 and version 4 framework with raster effects. If I have the code below and run it in a WPF application using the .NET Framework 4 client profile, the bitmap effect will not appear. If I installed the frame version in the .NET Framework 3.5 client profile (and did not change the code), it will work as expected. At first I thought it was a problem in my application, but I deleted the code and put it in a separate standalone application, and it behaves the same. Does anyone else check that the same problem is happening?

What's going on here?

The version 4 structure in VS2010 simply ignores the effect of the bitmap.

<Window.Resources> <Style x:Key="SectionHeaderTextBlockStyle" TargetType="{x:Type TextBlock}"> <Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="FontSize" Value="18"/> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="Foreground" Value="LightGreen"/> <Setter Property="BitmapEffect"> <Setter.Value> <OuterGlowBitmapEffect GlowColor="Black" GlowSize="3" /> </Setter.Value> </Setter> </Style> </Window.Resources> <Grid VerticalAlignment="Center" HorizontalAlignment="Center"> <TextBlock Text="Contact Details" Style="{DynamicResource SectionHeaderTextBlockStyle}"/> </Grid> 
+4
source share
5 answers

As others have said: .NET 4.0 no longer supports BitmapEffects.

As additional information: Since there is no OuterGlowEffect that you can use with the Effect property (at least I know), you can replace the bitmap effect with DropShadowEffect and set the ShadowDepth property to 0. Then you can create a glow effect by adjusting the property BlurRadius . In addition, you can also set the Color property if you want the glow to have a different color than black, but as I can see from your code example, you are actually using black as GlowColor .

I know that this workaround may not be as flexible and convenient as OuterGlowBitmapEffect , and it does not give the same results, but at least it is close in some situations, and it is definitely easier than writing a pixel shader ..

+12
source

As pointed out here by Microsoft, BitmapEffect deprecated from .NET 4. Use Effect instead.

+4
source

BitmapEffects are no longer supported in .NET 4.0.

Instead, you should use the Effect property.

See here for more details.

+3
source

According to this blog post :

5. In the BitmapEffect classes, there are now no-ops.
BitmapEffect is used for rendering in software and has caused priority problems. BitmapEffect still exists, so your applications will compile, but BitmapEffect will not do anything.

+1
source

Check out Bitmap Effects , which explains some issues when using the new GPU-based effects.

0
source

Source: https://habr.com/ru/post/1310190/


All Articles