这篇文章的目的是解释如何以及什么时候使用CMdaImageFileToBitmapUtility API。本文所附的例子程序增强和演示CMdaImageFileToBitmapUtility API。例子程序允许用户从他们的电话中选择一个图像进行变换和现实。例子程序已经在下列的电话中成功运行:
l Motorola A1000
l Motorola M1000
示例应用中的类
示例程序中的主要类如下所示:
图1 示例应用中可用的类
总述
CMdaImageFileToBitmapUtility API的允许开发者打开图像文件,然后转化为位图。CMdaImageFileToBitmapUtility类本身使用另外一个图像变换接口,CMdaImageUtility,为了完成实际的转换。然而,开发者没有必要了解这个API。更多的细节参考Symbian API文档。
简介
这篇文章描述的源代码在示例应用中的ImgConverter中可用。本文集中讲解实例化和使用CMdaImageFileToBitmapUtility API。
实例化和使用
CMdaImageFileToBitmapUtility API的NewL函数声明如下所示:
static CMdaImageFileToBitmapUtility* NewL(MMdaImageUtilObserver&
aObserver,CMdaServer* aServer = NULL);
本文所附的ImgConverter示例程序使用从MMdaImageUtilObserver接口衍生的CImgConversionEngine类的作为第一个参数。CImgConversionEngine类可以被使用,因为它衍生自MMdaImageUtilObserver类,并且实现了该类的三个虚函数。示例程序忽略了第二个可选的CMdaServer类型参数。第二个参数可能会被用到,如果CMdaImageFileToBitmapUtility实例被多个调用者创建,并且需要明了哪一个调用者的回调方法需要接受事件。
那么,当如下创建CMdaImageFileToBitmapUtility实例时,CMdaImageFileToBitmapUtility通过三个回调函数通知调用者成功或者不成功的操作。
iUtility = CMdaImageFileToBitmapUtility::NewL( *this );
为了使CMdaImageFileToBitmapUtility对象能够被通知,MMdaImageUtilObserver的三个虚函数需要被调用者实现。
virtual void MiuoConvertComplete(TInt aError) = 0;
virtual void MiuoCreateComplete(TInt aError) = 0;
virtual void MiuoOpenComplete(TInt aError) = 0;
一旦创建了CMdaImageFileToBitmapUtility类,它的OpenL函数可以被调用打开指定的图像文件。这个动作的结果在上面提及的MiuoOpenComplete回调中被返回。调用CMdaImageFileToBitmapUtility成员对象(示例代码中是iUtility)的CMdaImageUtility继承函数,ConvertL和Close将会变换和关闭选择的图像。ConvertL函数的结果被返回到调用者通过MiuoConvertComplete回调。
总结

您现在的位置: