惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
B
Blog
P
Proofpoint News Feed
美团技术团队
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
有赞技术团队
有赞技术团队
小众软件
小众软件
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
罗磊的独立博客
L
LangChain Blog
GbyAI
GbyAI
腾讯CDC
T
The Blog of Author Tim Ferriss
Microsoft Security Blog
Microsoft Security Blog

博客园 - Big Angel

N97 Firmware Update to V20 被PM了 小说Symbian的签名 如何在S60 5th中模拟触摸事件 - Big Angel Carbide C++ 2.0 Released 如何向Symbian C++程序中添加多语言支持 说说Hakone MX Revolution大革命入手 不能要求自己太严格了 Lie to me不错 Google开始加大推荐手机软件的力度 诺基亚2009挑战赛和Ovi Store Symbian UI 架构分类 微博客真的会流行么 如何升级Symbian Carbide C++的GCC编译器版本 QT Opensource Edition for Windows CE Installation with Visual Studio 2005 设计模式:浅谈行为模式State(C/C++ C#) Flickr WallPaper 红黑的宿命(米兰夺冠庆祝贴)
如何使用CImageEncoder进行图片压缩转换
Big Angel · 2009-05-13 · via 博客园 - Big Angel

以下代码示例说明如何在Symbian C++使用CImageEncoder进行bmp图片压缩和转换成Jpg图片。

Tested on: Nokia N958GB, Nokia 5800Xpress Music

1. 取得屏幕旋转方向和大小信息并截取当前屏幕

 1 //取得屏幕设备指针
 2 const CWsScreenDevice* screenDevice = iCoeEnv.ScreenDevice();
 3     
 4 //取得屏幕大小和方向信息
 5 screenDevice->GetScreenModeSizeAndRotation(
 6   screenDevice->CurrentScreenMode(), iSizeAndRotation);
 7 
 8 //截屏操作
 9 CFbsBitmap* iBitmap = new (ELeave) CFbsBitmap();
10     iBitmap->Create(iSizeAndRotation.iPixelSize, screenDevice->DisplayMode());
11 
12 iBitmap->SetSizeInTwips(screenDevice);
13 
14 screenDevice->CopyScreenToBitmap(iBitmap);

2. 设置需要转化文件的格式和参数,使用异步方法进行压缩。

 1 //生成一个CFrameImageData对象的指针
 2 CFrameImageData* frameImageData = CFrameImageData::NewL();
 3 CleanupStack::PushL(frameImageData);
 4 
 5 //转化成Jpeg格式的参数设定,iSampleScheme,iQualityFactor
 6 TJpegImageData* imageData = new (ELeave) TJpegImageData();
 7 imageData->iSampleScheme  = TJpegImageData::EColor444;
 8 imageData->iQualityFactor = iSettingData.ImageQuality();
 9 User::LeaveIfError(frameImageData->AppendImageData(imageData));
10 
11 //DataNewL方法来制定转换的格式和方法
12 iImageEncoder = CImageEncoder::DataNewL
13     (iCapturedImageBuffer, KImageTypeJpg, CImageEncoder::EOptionAlwaysThread);
14     
15 //异步请求转化为指定格式的文件
16 iImageEncoder->Convert(&iStatus, *iBitmap, frameImageData);
17 
18 CleanupStack::PopAndDestroy(frameImageData);
19 

上述代码片段由于使用了异步方法,需要在活动对象中(Active Object)使用。

同理,使用CImageEncoder也可进行其他图片格式的转换。