I am getting the same error with an empty WIC premultiplied BGRA bitmap.
HRESULT hr = S_OK;
IWICBitmap* pWICBitmap = NULL;
ID2D1Bitmap1* pD2DBitmap = NULL;
// An useless empty bitmap, it's just for testing..
hr = g_pWICFactory->CreateBitmap(
1920,
1080,
GUID_WICPixelFormat32bppPBGRA,
WICBitmapCacheOnLoad,
&pWICBitmap );
if ( SUCCEEDED( hr ) )
{
D2D1_BITMAP_PROPERTIES1 properties = { };
properties.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM;
properties.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
properties.dpiX = 96.0f;
properties.dpiY = 96.0f;
properties.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET;
properties.colorContext = NULL;
hr = pDeviceContext->CreateBitmapFromWicBitmap(
pWICBitmap,
&properties,
&pD2DBitmap );
if ( FAILED( hr ) ) // E_INVALIDARG !!
{
SAFE_RELEASE( pD2DBitmap );
}
}
SAFE_RELEASE( pWICBitmap );
---
Everything works fine with this method :
//
// Creates a bitmap with extended bitmap properties, potentially from a block of
// memory.
//
STDMETHOD(CreateBitmap)(
D2D1_SIZE_U size,
_In_reads_bytes_opt_(size.height * pitch) CONST void *sourceData,
UINT32 pitch,
_In_ CONST D2D1_BITMAP_PROPERTIES1 *bitmapProperties,
_Outptr_ ID2D1Bitmap1 **bitmap
) PURE;