GDI+ PNG Transparency
-
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 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 -
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 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 DavidFill the client rect with grey before DrawImage or change your image.