locked
How to get image buffer by WIC?

    Question

  • Dears,

    How can I get the image buffer using WIC library?

    I use BitmapSource copyPixels but failed.

    hr = bitmapSource.As<IWICBitmapSource>(&wicBitmap);
    //return S_OK
    //then I call
    BYTE *pImgBuffer = new BYTE[width * height * 4];
    WICRect rcLock = { 0,0,width,height};
    hr = wicFactory->createBitmapFromSource(wicBitmap.Get(),
           WICBitmapCacheOnDemand, &bitmap);
    
    if (SUCCEEDED(hr))
        hr = wicBitmap->CopyPixels(rcLock, width * 4 ,              cbBufferSize, pImgBuffer);
    // failed here : the buffer allocated is insufficient!!
    

    Why??

    Tuesday, December 25, 2012 9:48 AM

Answers