I have a C++ project which uses Windows Animation Manager with Direct2D under Visual Studio 2010 to implement image sparkled animation.
But when I load a png image, the transparent can’t display correctly.
I use IWICImagingFactory and IWICBitmap to load the png image, and then create a D2D bitmap from the WIC bitmap. The D2D1_PIXEL_FORMAT’s alphaMode set as D2D1_ALPHA_MODE_PREMULTIPLIED and format set as DXGI_FORMAT_B8G8R8A8_UNORM. It seems only opaque and transparent without semitranslucent. And I try to change the D2D1_PIXEL_FORMAT’s alphaMode to D2D1_ALPHA_MODE_STRAIGHT but it doesn’t work.
I also follow the sample code from MSDN ( http://msdn.microsoft.com/en-us/library/windows/desktop/ee719658(v=vs.85).aspx ), but nothing display. Can someone help me that how to load a png image and transfer to ID2D1Bitmap with correct alpha value? Thanks!
Asked
Active
Viewed 1,380 times
-2

Freya
- 51
- 5
1 Answers
1
I already solved my question from the example code under \Microsoft SDKs\Windows\v7.1\Samples\multimedia\wic\wicviewerd2d. The important keyword is GUID_WICPixelFormat32bppPBGRA when initialize the IWICFormatConverter object.

Freya
- 51
- 5