Media Server Image Converter API
	
Author:	Lane Roberts	
Last revised:	13th October 1999	

Contents
1. Introduction	
1. 1 Purpose and scope	
1. 2 Document History	
2. Overview	
3. Functional specification	
3. 1 Rotation	
3. 2 Scaling	
3. 3 Conversions	
3. 3 .1 File to bitmap	
3. 3 .2 Descriptor to bitmap	
3. 3 .3 Bitmap to file	
3. 3 .4 Bitmap to descriptor	
3. 3 .5 Bitmap to bitmap	
3. 3 .6 Asynchronous operation signalling	
3. 4 Image frame information	

 1.	
Introduction
 1. 1	Purpose and scope
This document describes Image Converter API.  This interface is intended to be used to perform common conversion operations on images.
 1. 2	Document History
Date	Revision	Status	Description	
13-10-1999	1	Draft	First draft taken from the Image API Requirements Spec document	

 2.	Overview
The Media Server Image Utility API provides a number of classes, each one dedicated to a specific image operation.  These operations are a subset of all possible ordered pairings of the following set of source/destination types:
•	Image file
•	In-memory bitmap (CFbsBitmap/CWsBitmap)
•	Memory descriptor (complete image data)

Media Server operations are essentially asynchronous so notification of completion is passed back to the calling code.
 3.	
Functional specification
 3. 1	Rotation
The following specifies the functionality required for rotation.

class CMdaBitmapRotator : public CBase
	{
public:
enum ERotationAngle
{
ERotation90DegreesClockwise,
ERotation180DegreesClockwise,
ERotation270DegreesClockwise
};
public:
void RotateL(MMdaImageUtilObserver& aObserver,CFbsBitmap& aSrcBitmap,
CFbsBitmap& aTgtBitmap,TRotationAngle aAngle);
void RotateL(MMdaImageUtilObserver& aObserver,CFbsBitmap& aBitmap,	TRotationAngle aAngle);
void CancelRotation();
	};
 3. 2	Scaling
The following specifies the functionality required for scaling.

class CMdaBitmapScaler : public CBase
	{
public:
void ScaleL(MMdaImageUtilObserver& aObserver,CFbsBitmap& aSrcBitmap,
CFbsBitmap& aTgtBitmap,TBool aMaintainAspectRatio = ETrue);
void ScaleL(MMdaImageUtilObserver& aObserver,CFbsBitmap& aBitmap,
TSize aDestSize,TBool aMaintainAspectRatio = ETrue);
void CancelScaling();
};

 3. 3	Conversions
The following class declarations specify the functionality required for conversions.  The common conversion and information functions are defined in an abstract base class.  This allows the user to write polymorphic code for handling image conversion classes.

class CMdaImageUtility : public CBase
	{
public:
// Image conversion
	virtual void ConvertL(CFbsBitmap& aBitmap,TInt aFrameNumber = 0) = 0;
	virtual void ConvertL(CFbsBitmap& aBitmap,const TRect& aSourceRect,
TInt aFrameNumber = 0) = 0;
	virtual void CancelConvertL() = 0;
// Image information
	virtual const TFrameInfo& FrameInfo(TInt aFrame) const;
	virtual TInt FrameCount() const;
	};

 3. 3 .1	File to bitmap

class CMdaImageFileToBitmapUtility : public CMdaImageUtility
	{
public:
// Object management
	CFileToBitmap* NewL(MMdaImageUtilObserver& aObserver,
CMdaServer* aServer = NULL);
void OpenL(const TDesC& aFileName,TMdaClipFormat* aFormat = NULL,
TMdaPackage* aCodec = NULL,TMdaPackage* aExtra = NULL);
	void Close();
// Image conversion
	virtual void ConvertL(CFbsBitmap& aBitmap,TInt aFrameNumber = 0);
	virtual void ConvertL(CFbsBitmap& aBitmap,const TRect& aSourceRect,
TInt aFrameNumber = 0);
	virtual void CancelConvertL();
// Image information
	virtual const TFrameInfo& FrameInfo(TInt aFrame) const;
	virtual TInt FrameCount() const;
	};

 3. 3 .2	Descriptor to bitmap

class CMdaImageDescToBitmapUtility : public CMdaImageUtility
	{
public:
// Object management
	CFileToBitmap* NewL(MMdaImageUtilObserver& aObserver,
CMdaServer* aServer = NULL);
void OpenL(const TDesC8& aDescriptor,TMdaClipFormat* aFormat = NULL,
TMdaPackage* aCodec = NULL,TMdaPackage* aExtra = NULL);
	void Close();
// Image conversion
	virtual void ConvertL(CFbsBitmap& aBitmap,TInt aFrameNumber = 0);
	virtual void ConvertL(CFbsBitmap& aBitmap,const TRect& aSourceRect,
TInt aFrameNumber = 0);
	virtual void CancelConvertL();
// Image information
	virtual const TFrameInfo& FrameInfo(TInt aFrame) const;
	virtual TInt FrameCount() const;
	};

 3. 3 .3	Bitmap to file

class CMdaImageBitmapToFileUtility : public CMdaImageUtility
	{
public:
// Object management
	CFileToBitmap* NewL(MMdaImageUtilObserver& aObserver,
CMdaServer* aServer = NULL);
void CreateL(const TDesC& aFileName,TMdaClipFormat* aFormat,
TMdaPackage* aCodec,TMdaPackage* aExtra);
	void Close();
// Image conversion
	virtual void ConvertL(CFbsBitmap& aBitmap,TInt aFrameNumber = 0);
	virtual void ConvertL(CFbsBitmap& aBitmap,const TRect& aSourceRect,
TInt aFrameNumber = 0);
	virtual void CancelConvertL();
// Image information
	virtual const TFrameInfo& FrameInfo(TInt aFrame) const;
	virtual TInt FrameCount() const;
	};

 3. 3 .4	Bitmap to descriptor

class CMdaImageBitmapToDescUtility : public CMdaImageUtility
	{
public:
// Object management
	CFileToBitmap* NewL(MMdaImageUtilObserver& aObserver,
CMdaServer* aServer = NULL);
void CreateL(HBufC8& aDescriptor,TMdaClipFormat* aFormat,
TMdaPackage* aCodec,TMdaPackage* aExtra);
	void Close();
// Image conversion
	virtual void ConvertL(CFbsBitmap& aBitmap,TInt aFrameNumber = 0);
	virtual void ConvertL(CFbsBitmap& aBitmap,const TRect& aSourceRect,
TInt aFrameNumber = 0);
	virtual void CancelConvertL();
// Image information
	virtual const TFrameInfo& FrameInfo(TInt aFrame) const;
	virtual TInt FrameCount() const;
	};

 3. 3 .5	Bitmap to bitmap

class CMdaImageBitmapToBitmapUtility : public CMdaImageUtility
	{
public:
// Object management
	CFileToBitmap* NewL(MMdaImageUtilObserver& aObserver,
CMdaServer* aServer = NULL);
void OpenL(CFbsBitmap& aBitmap);
	void Close();
// Image conversion
	virtual void ConvertL(CFbsBitmap& aBitmap,TInt aFrameNumber = 0);
	virtual void ConvertL(CFbsBitmap& aBitmap,const TRect& aSourceRect,
TInt aFrameNumber = 0);
	virtual void CancelConvertL();
// Image information
	virtual const TFrameInfo& FrameInfo(TInt aFrame) const;
	virtual TInt FrameCount() const;
	};

 3. 3 .6	Asynchronous operation signalling
All functions complete immediately but the operations initiated by some are asynchronous.  Completion of the operation is signalled by the object calling the appropriate observer function on an instantiation of a class derived from MMdaImageUtilObserver:

class MMdaImageUtilObserver
	{
public:
	virtual void MiuoCreateComplete(TInt aError) = 0;
	virtual void MiuoOpenComplete(TInt aError) = 0;
	virtual void MiuoConvertComplete(TInt aError) = 0;
	};
 3. 4	Image frame information
Image frame information is supplied in a TFrameInfo object:

class TFrameInfo
	{
public:
	TSize iSizeInPixels;
	TSize iSizeInTwips;
	TInt iBitsPerPixel;
	TBool iColor;
	TPoint iOffsetInPixels;
	TTimeMicroSeconds iDelay;
	};

Image information is available once the OpenL()or CreateL() function has completed successfully.