Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GDI+ PNG Transparency

GDI+ PNG Transparency

Scheduled Pinned Locked Moved C / C++ / MFC
graphicswinforms
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ClickHeRe
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • C ClickHeRe

      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

      D Offline
      D Offline
      douglasjordan
      wrote on last edited by
      #2

      Fill the client rect with grey before DrawImage or change your image.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups