Windows Phone image processing and format support has always been lacking a bit, especially when compared with all the GDI+ capabilities one has available in the full .NET Framework.
For instance, you can read JPEG and PNG files, but you can only save to JPEG, as there is no support to save to PNG directly on the platform.
Saving to PNG has been quite easy since the beginning of Windows Phone 7 by using 3rd party libraries, and on this chapter, .NET Image Tools is the most used one!
But personally, using Image Tools always presented two major problems:
- it requires SharpZipLib (a GPL licensed library) to handle Zlib compression
- it’s quite slow and uses a lot of memory
The first problem is a definitive “no-no” for usage in closed code commercial apps, as GPL is ”viral license”
The second problem is more related to the way Image Tools was developed, not considering usage in mobile devices that have lower specifications as to processor capacity or memory.
The Cimbalino Windows Phone Toolkit way
Cimbalino Windows Phone Toolkit version 3.2.0 presents a new WriteableBitmapExtensions containing a SavePng()
method to create PNG files from WriteableBitmap instances!
Internally it uses DotNetZip (Ms-Pl license) to handle the required ZLib compression and it’s quite optimized for speed and low memory consumption.
To illustrate the speed improvement, Ertay Shashko was kind enough to test it with his Tile Me app, and here are the results of his personal usage:
@pedrolamas Imagetools (~2.5 seconds to generate): http://t.co/LS5Lj1ZSCq Cimbalino (Default, ~0.7 secs to gener.): http://t.co/Hv0CAOK8K6
— Ertay Shashko (@ErtaySh) November 6, 2013
I guess the numbers speak for themselves! :)