Gdiplus Graphics & HDC transparency

Started by
0 comments, last by HPSC 11 years, 8 months ago
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
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.

This topic is closed to new replies.

Advertisement