Symbian編程總結-圖形映像篇-開啟非Bitmap類型的映像

來源:互聯網
上載者:User

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。

點擊此處下載原始碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.