views:

34

answers:

0

I am trying to create a PNG bitmap with RGB+A info. I want to draw a rectangle on the bitmap that is semi transparent (In other words, R=255, G=255, B=255 A = 128). I am using managed code so either SlimDX or the codepack API. The most straight forward route appears to be using the codepack api and WIC so I created a WIC bitmap with: wicFactory.CreateWICBitmap(size.Width, size.Height, PixelFormats.Pf32bppPBGRA, BitmapCreateCacheOption.CacheOnLoad)

and then I created a WIC Render target using DXGI.Format.B8G8R8A8_UNORM and AlphaMode.Premultiplied. It looks like I should be using AlphaMode.Striaght but there is no supported render target that allows straight and 32 bbp that I can find. For sure, not the WIC render target or the DC compatible Render Target that looks like the best way to get a bit map back.

Using the above combination, I always get back a bit map with the alpha channel set to 255 and the color channels scaled depending on what alpha value I specified which is how I understand premultiplied to work. Any ideas on how I can get direct2D to generate a bit map with an alpha channel other than 255? (the end objective is to layer this bit map over another one and see some of the contents of the underneath bitmap which won't happen with an alpha of 255).

On a closely related note, is there any way to get at the bits behind a Direct2D bitmap? All my testing requires me to convert to PNG and save it to a stream so I can look at the bits. It would be nice to be able to dump the raw bitmap data before conversion to see what is happening there.

This question seems very close to: http://stackoverflow.com/questions/2603276/how-do-i-clear-a-direct2d-render-target-to-fully-transparent but there is no answer there either.

Thanks in advance!

Brian