Symbian OS不仅原生的支持Bitmap位图,还可以使用CImageDecoder类对jpeg/gif/png类型的图像进行编码和解码。

CImageDecoder可以从文件创建,也可以从描述符中创建,具体创建方法请参看SDK。

CImageDecoder要结合活动对象使用,使用的方法很简单:

void CImageHelper::LoadPngImageL(TDesC& aFileName, CFbsBitmap* aBitmap, CFbsBitmap* aBitmapMask)
    {

    if (iImgDecoder)
        {
        iImgDecoder->Cancel();
        delete iImgDecoder;
        iImgDecoder = NULL;
        }

    // 获取图片
    iImgDecoder = CImageDecoder::FileNewL(iFs, aFileName, KMIMEType);
    TSize size = iImgDecoder->FrameInfo().iOverallSizeInPixels;
    TDisplayMode mode = iImgDecoder->FrameInfo().iFrameDisplayMode;

    // 创建位图
    User::LeaveIfError(aBitmap->Create(size, mode));
    User::LeaveIfError(aBitmapMask->Create(size, EGray256));

    // 调用转换异步函数
    iStatus = KRequestPending;
    iImgDecoder->Convert(&iStatus, *aBitmap, *aBitmapMask);

    SetActive();
    iActiveSchedulerWait->Start();
    }

其中,KMIMEType为图像文件的MIME类型,对应jpeg、gif、png分别为image/jpeg、image/gif、image/png。

点击此处下载源代码

Symbian编程总结-图形图像篇-打开非Bitmap类型的图像

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-09-03
  • 2021-07-09
  • 2022-01-07
  • 2021-11-22
  • 2022-12-23
  • 2022-01-02
  • 2021-10-02
相关资源
相似解决方案