Hello.
I'm stuck with this issue that I can't seem to be able to get past.
I'm trying to load an image using WIC and pass it to Direct2D.
// create wic format converter
hres = m_pWicFactory->CreateFormatConverter( &m_pWicConverter );
// setup the converter to create 32bpp BGRA bitmaps
hres = m_pWicConverter->Initialize( m_pBitmapFrame.Get(),
GUID_WICPixelFormat32bppBGRA, // Pixel Format
WICBitmapDitherTypeNone,
nullptr,
0.0,
WICBitmapPaletteTypeCustom );
// create the D2D1 bitmap
hres = gph->getRenderTarget()->CreateBitmapFromWicBitmap( m_pWicConverter.Get(),
nullptr,
&m_pBitmap ); // failure here "The bitmap pixel format is unsupported."
Meanwhile my ID2D1HwndRenderTarget
is created like so:
hres = m_pFactory->CreateHwndRenderTarget( D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_TYPE_HARDWARE,
D2D1::PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM ) ),
D2D1::HwndRenderTargetProperties( hWnd,
size ),
&m_pRenderTarget );
As you can see both are BGRA 8 bit per channel - the recommended format.
What am I doing wrong?
I'm on MSVS 2017.