What's best performance way to constantly change image on WP7?

Posted by AlRodriguez on Stack Overflow See other posts from Stack Overflow or by AlRodriguez
Published on 2011-02-25T07:07:59Z Indexed on 2011/02/25 7:25 UTC
Read the original article Hit count: 123

Filed under:
|
|
|

I'm trying to make my own type of remote desktop for WP7. I have a WCF service that returns an image on what's on the target machine's screen.

Here's the WCF Server Code:

    // Method to load desktop image
Bitmap image = new Bitmap( ViewSize.Width, ViewSize.Height );
Graphics g = Graphics.FromImage( image );

g.CopyFromScreen( Position.X, Position.Y, 0, 0, ViewSize );

g.Dispose( );
return image;

// Convert image to byte[] which is returned to client
using ( MemoryStream ms = new MemoryStream( ) )
{
    Bitmap image = screenGrabber.LoadScreenImage( );
    image.Save( ms, ImageFormat.Jpeg );
    imageArray = ms.ToArray( );
}

Here's the code for the WP7 client:

    MemoryStream stream = new MemoryStream( data );
BitmapImage image = new BitmapImage( );

image.SetSource( stream );
BackgroundImage.Source = image;

The BackgroundImage variable is an Image control.

I'm noticing this freeze on the emulator after a short while, and will eventually crash from an OutOfMemoryException. This is already pretty slow ( images show up a good half second later than what's on the screen ), and I'm wondering if there's a better/faster way of doing this? Any help would be great. Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf