I've been encouraged to blog about a new feature available as a part of newly released beta 1 of OpenNETCF SDF - the Imaging API wrapper.
The Imaging API is an attempt to bring Image codec support from the desktop GDI+ to mobile devices. It is implemented as a set of COM interfaces available to C/C++ applications. There is a cocreatable class ImagingFactory and a bunch of interfaces that allow loading, saving and manipulating the images. Effective 1.0 SP2 Compact Framework uses this API internally to load (and in 2.0 to save) images instead of imgdecmp.dll used in CF1 SP1 and before.
In CF2 it became possible to wrap COM interfaces for use in the managed applications. The Bitmap class is also significantly richer than before. Given this, one would ask what would be the reason to try using Imaging API directly. Here is a brief list of things that are not part of the CF2 Bitmap class:
- Access to image tags (EXIF header etc)
- Image transformation (flip, rotate, gamma/brightness/contrast controls)
- Thumbnails, loading parts of the large image
The Imaging wrapper is located inside OpenNetCF.Drawing components as OpenNetCF.Drawing.Imaging namespace. On top of the basic interfaces it offers a small utility layer presented as ImageUtils class. ImageUtils has the following high-level methods:
- Bitmap RotateFlip(Bitmap bitmap, RotateFlipType type)
- Bitmap Flip(Bitmap bitmap, bool flipX, bool flipY)
- Bitmap IBitmapImageToBitmap(IBitmapImage imageBitmap)
- IBitmapImage BitmapToIImageBitmap(Bitmap bitmap)
- IBitmapImage CreateThumbnail(Stream stream, Size size)
The last method - CreateThumbnail - allows loading a small thumbnail instead of a large image. Most Pocket PC devices won't be able to load and display a 5-6 megapixel image produced by most digital cameras. At the same time one can easily load 640x480 thumbnail that will let one implement basic zoomable view.
In the next couple of days I'm going to provide a few code samples. Stay tuned.