Bitmap animations on multiple screens

hell?!

I am currently developing a WPF application which shows various bitmaps and uses some effects like animations of the Opacity property of System.Windows.Controls.Image objects. The application should be able to be run on two screens. Either I will do this with two windows, one for each screen, which have some kind of communication, or I will just use one big window which stretches over both screens. I have already implemented the second option and I'm getting into performance issues as soon as the window size is about 1.5 screens or bigger.

Is there a preferred way to do this in WPF?

Thanks for the help!
Jonas

[638 byte] By [Cheeeeesus] at [2008-1-10]
# 1

Could you shed some more light on where you are seeing the performance problems - always when animating, etc?

Also, is it possible to post a little repro of you app?

SteveGalic-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2
Thank you for your answer!
The "performance problems" are simply that the animations (like fading out images etc.) are running not as smooth as they do when the window is smaller. Here is some sample code:

Code Block

public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
DoubleAnimation image1Animation = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(.5));
DoubleAnimation image2Animation = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(.5));
image1Animation.AutoReverse = image2Animation.AutoReverse = true;
image1Animation.RepeatBehavior = image2Animation.RepeatBehavior = RepeatBehavior.Forever;
image1.BeginAnimation(FrameworkElement.OpacityProperty, image1Animation);
image2.BeginAnimation(FrameworkElement.OpacityProperty, image2Animation);
}
}

<Window x:Class="WPFTwoScreensPerformanceTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPFTwoScreensPerformanceTest" Height="442" Width="800"
>
<Window.Resources>
<ImageSource x:Key="image1">image1.jpg</ImageSource>
<ImageSource x:Key="image2">image2.jpg</ImageSource>
</Window.Resources>
<Grid>
<Image x:Name="image1" Source="{StaticResource image1}" Opacity="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Image x:Name="image2" Source="{StaticResource image2}" Opacity="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
</Window>


If you put some (rather large) bitmaps into your project as "image1.jpg" and "image2.jpg" and resize the window to a size bigger than one screen, there is a point when CPU usage suddenly increases, and the animations are not as smooth as they are with a smaller window.
Cheeeeesus at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3

What version of WPF are you running this under? Under 3.5 things looked smooth for me no matter how large I made the window or how it was located between the 2 screens.

We did some work on making animations smoother in 3.5, which may be what I am seeing.

You also may look into lowering the desired frame rate for animations that are overly CPU intensive. Dropping it to 30-40 can improve performance without sacrificing too much visual quality:

http://msdn2.microsoft.com/en-us/library/system.windows.media.animation.timeline.desiredframerate.aspx

SteveGalic-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 4
Thank you, I'll try out your suggestions.

So, there should not be any significant difference in performance whether the animations are running on two windows (one for each screen) or on one big window which stretches over two screens?

Thanks and best regards

Cheeeeesus at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified