DropShadowEffect和OuterGlowBitmapEffect动画占用了太多的CPU和内存?

时间:2011-05-16 09:42:20

标签: wpf

动画DropShadoweffect和OuterGlowBitmapEffect继续增加内存和CPU使用率。为什么它需要占用太多内存和CPU,有没有办法减少或避免?

<Window.Resources>
    <Storyboard x:Key="Storyboard1">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" 
        Storyboard.TargetName="textBlock" 
        Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.BlurRadius)"
    RepeatBehavior="Forever">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.9000000" Value="25"/>
        </DoubleAnimationUsingKeyFrames>

    </Storyboard>
</Window.Resources>
<Window.Triggers>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
        <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
    </EventTrigger>
</Window.Triggers>

<Grid x:Name="LayoutRoot">
    <TextBlock x:Name="textBlock" HorizontalAlignment="Left" VerticalAlignment="Top" Text="Drop Shadow Effect" TextWrapping="Wrap" Margin="189,126,0,0" FontWeight="Bold">
        <TextBlock.Effect>
            <DropShadowEffect ShadowDepth="5" BlurRadius="0"/>
        </TextBlock.Effect>
    </TextBlock>
</Grid>

1 个答案:

答案 0 :(得分:2)

没有 OuterGlowEffect 这样的课程。

你的意思是 OuterGlowBitmapEffect 吗?如果是这样,这是一个已弃用的类,已知性能问题,可以解释您的问题。使用 BlurEffect 或其他 DropShadowEffect 代替达到您想要的效果。 (另外,请确保您没有使用已弃用的 DropShadowBitmapEffect 。)

但它也可能是您的代码的问题,在这种情况下,请将其发布!