Pocket中使用IImage

頭文件的包含順序很重要 
#include <initguid.h>
#include <imaging.h>
其中<initguid.h>一定要在<imaging.h>之前,否則會出現錯誤,然後實例代碼入下
    IImagingFactory *pImgFactory = NULL;
    IImage *pImage = NULL;
    RECT rc = { 0, 0, 110, 88};
    // Normally you would only call CoInitialize/CoUninitialize
    // once per thread.  This sample calls CoInitialize in this
    // draw function simply to illustrate that you must call 
    // CoInitialize before calling CoCreateInstance.
    CoInitializeEx(NULL, COINIT_MULTITHREADED);
    // Create the imaging factory.
    if (SUCCEEDED(CoCreateInstance (CLSID_ImagingFactory,
                                    NULL,
                                    CLSCTX_INPROC_SERVER,
                                    IID_IImagingFactory,
                                    (void **)&pImgFactory)))
    {
        // Load the image from the JPG file.
        if (SUCCEEDED(pImgFactory->CreateImageFromFile(
                        TEXT("//Program Files//Imaging//flower.jpg"),
                        &pImage)))
        {
            // Draw the image.
            pImage->Draw(hdc, &rc, NULL);

            pImage->Release();
        }
        pImgFactory->Release();
    }
    CoUninitialize();
發佈了40 篇原創文章 · 獲贊 4 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章