Click to See Complete Forum and Search --> : GDI+ PNG Transparency


ClickHeRe
November 22nd, 2005, 07:46 PM
Using GDI+ to load a PNG 32 bit image with transparency.

I draw the image on a static control and I get this result :

Image (http://dcx.scriptsdb.org/test.png)

with this code in the WM_PAINT :

case WM_PAINT:
{
if ( this->m_pImage != NULL ) {

PAINTSTRUCT ps;
HDC hdc;

hdc = BeginPaint( this->m_Hwnd, &ps );

RECT rect;
GetClientRect( this->m_Hwnd, &rect );

Graphics grphx( hdc );
grphx.DrawImage( this->m_pImage, 0, 0, rect.right - rect.left, rect.bottom - rect.top );

EndPaint( this->m_Hwnd, &ps );

bParsed = TRUE;
return 0L;
}
}
break;


I'd like to have the transparent part stay grey.

Thanks

David

kirants
November 22nd, 2005, 07:56 PM
Hm.. before you call DrawImage, paint the rect grey.. using FillRect or Rectangle GDI functions.