Jump to content
  • Advertisement
Sign in to follow this  
HPSC

Gdiplus Graphics & HDC transparency

This topic is 2222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am creating a gdiplus bitmap then a graphics object and getting an HDC from teh graphics object. I pass the HDC into a DLL to be drawn on (it used gdiplus in the dll to draw lines, polygons etc)


Gdiplus::Bitmap mem_dc(Width, Height, PixelFormat32bppARGB );
Gdiplus::Graphics g(&mem_dc);
HDC hDC = g.GetHDC();
DllObject->Render(hDC);
g.ReleaseHDC(hDC);


In the DLL I have a 3rd party sdk that can use the hDC or a gdiplus bitmap, I have tried both ways but I have having a problem rendering transparency.


Gdiplus::Bitmap mem_dc(m_CanvasWidth, m_CanvasHeight, PixelFormat32bppARGB );
m_pView->Render(mem_dc);
Gdiplus::Graphics g(hDC);
g.DrawImage(&mem_dc, 0.0f, 0.0f);


The sdk draws an blended overlay that I draw on top of another image, but when I render with these methods it seems to have already blended with black.

Using the sdk directly rather than in a DLL and a bitmap works as I want it. You might ask why I don't do that, well I am doing terrible things... The sdk is old so I am wrapping it in a DLL with a pure virtual interface so I can use it a different compiler, my test set up for this seems to work (this is based on a codeproject article http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL#CppMatureApproach ), and that is why I am passing a HDC across the boundary. If anyone knows if this is somehow possible with gdiplus objects that would be great.

Thanks

Share this post


Link to post
Share on other sites
Advertisement
I found a different solution that meets my needs, just pass the Scan0 pointer over and memcpy from one bitmap to another. Though if anyone have a better solution I am all ears.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!