Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resizing images on Windows Phone 7 on thread pool thread?

I'm writing a Windows Phone 7 app that deals with a lot of images - These images can range from a few hundred pixels up to 1080P (Potentially higher in future).

Images are very resource intensive so I've gone down the path of caching + resizing images on the phone before displaying them.

This means on first time setup after a user has entered the IP address of the image store I can ask them to wait a few minutes while it's all retrieved/resized/cached. From then on they can have nice and snappy performance.

At the moment my cache manager tracks Images by a dictionary of Uri's and file locations. I have a Queue that processes up to 5 images at a time (Async web requests, resizing is semi done on thread pool thread).

The problem I have is that the WritableBitmap class in Silverlight is a UI element, meaning I have to transition to the UI thread via the Dispatcher to do the actual resizing which is stupid and slows the whole thing down - It also means my Cache Manager is effectively single threaded.

So it goes Cache Manager (Thread Pool) -> Async Web request (Thread Pool) -> Callback (Thread Pool) -> Resizing (UI Thread) -> Marking cache job as complete (Thread Pool).

I've been looking for a 3rd party library that will A) Compile and run on Windows Phone 7 and B) Be able to resize images of various formats by manipulating a stream or byte array and not be dependent on the UI thread.

Any one had any experience with this?

Cheers,

Tyler

like image 391
Tyler Avatar asked Mar 12 '11 06:03

Tyler


1 Answers

In order to reduce the download size and in order to remove the burden of processing from the phone CPU, then I'd push this work out to a web service.

For example, you could host a service like the open source WebImageResizer code somewhere online http://webimageresizer.codeplex.com/ - e.g. on a free AppHarbor server.

Or you could use a commercial (freemium) service like:

  • http://webresizer.com/app/
  • http://www.appspotimage.com/

Either of these would enable you to rapidly process the images on a server with a superfast connection and to juse deliver smaller images to the phone with its limited data connection.

like image 141
Stuart Avatar answered Nov 15 '22 18:11

Stuart