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. PNG Alpha blending/channel in VC++ 6.0?

PNG Alpha blending/channel in VC++ 6.0?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsc++winformsquestion
6 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.
  • S Offline
    S Offline
    StarMeteor
    wrote on last edited by
    #1

    Hi All, I am writing an application which try to show PNG file as a dialog background using GDI+ I have successfully using the PNG as background (using Graphics::DrawImage()), however, I found that the loaded PNG seems not apply the alpha channel information. What I should do? Thanks! (sorry for repeat posting if there is any) Vincent

    M 1 Reply Last reply
    0
    • S StarMeteor

      Hi All, I am writing an application which try to show PNG file as a dialog background using GDI+ I have successfully using the PNG as background (using Graphics::DrawImage()), however, I found that the loaded PNG seems not apply the alpha channel information. What I should do? Thanks! (sorry for repeat posting if there is any) Vincent

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Where in your code are you calling DrawImage()? What is the background behind the image and how is it drawn? Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      S 1 Reply Last reply
      0
      • M Mark Salsbery

        Where in your code are you calling DrawImage()? What is the background behind the image and how is it drawn? Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        S Offline
        S Offline
        StarMeteor
        wrote on last edited by
        #3

        I called it at OnEraseBackground() I would like to have a transparent background (i.e. I set the desktop background to black/white, I hope the image boundary will be "blur" with the work of alpha bending). I am not sure if what I do is right, however, with using the Graphics::SetCompositingMode(), it seems that the Graphics::DrawImage() method will not directly apply the alpha bending information? ( I use Bitmap::GetPixelFormat() to verify the input image is a PixelFormat32bppARGB type, which means it should include the alpha channel)

        M 1 Reply Last reply
        0
        • S StarMeteor

          I called it at OnEraseBackground() I would like to have a transparent background (i.e. I set the desktop background to black/white, I hope the image boundary will be "blur" with the work of alpha bending). I am not sure if what I do is right, however, with using the Graphics::SetCompositingMode(), it seems that the Graphics::DrawImage() method will not directly apply the alpha bending information? ( I use Bitmap::GetPixelFormat() to verify the input image is a PixelFormat32bppARGB type, which means it should include the alpha channel)

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          You shouldn't need much more than this...

          // Load a bitmap
          

          Bitmap SrcBitmap(L"C:\\Test.png", FALSE);

          ...

          // Draw the bitmap to the DC at 0,0
          

          Graphics DstGraphics(hdc);
              DstGraphics.SetCompositingMode(CompositingModeSourceOver);
              DstGraphics.DrawImage(&SrcBitmap, 0, 0, SrcBitmap.GetWidth(), SrcBitmap.GetHeight());

          If something's not working I'd have to see a code sample to possibly help :) Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          S 1 Reply Last reply
          0
          • M Mark Salsbery

            You shouldn't need much more than this...

            // Load a bitmap
            

            Bitmap SrcBitmap(L"C:\\Test.png", FALSE);

            ...

            // Draw the bitmap to the DC at 0,0
            

            Graphics DstGraphics(hdc);
                DstGraphics.SetCompositingMode(CompositingModeSourceOver);
                DstGraphics.DrawImage(&SrcBitmap, 0, 0, SrcBitmap.GetWidth(), SrcBitmap.GetHeight());

            If something's not working I'd have to see a code sample to possibly help :) Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            S Offline
            S Offline
            StarMeteor
            wrote on last edited by
            #5

            Hi Mark, Thanks for your reply ^^ err... what I wrote right now is exactly same as yours... (even the file name ) however, the outcome is just a dark background but not transparent... Maybe I put at a wrong message call location? I put the above code under OnEraseBackground() Vincent

            M 1 Reply Last reply
            0
            • S StarMeteor

              Hi Mark, Thanks for your reply ^^ err... what I wrote right now is exactly same as yours... (even the file name ) however, the outcome is just a dark background but not transparent... Maybe I put at a wrong message call location? I put the above code under OnEraseBackground() Vincent

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              Hmm...do you have a sample of a png image that isn't working that you can send me to test? Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              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