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. 32 bitmap and gdi+ problem

32 bitmap and gdi+ problem

Scheduled Pinned Locked Moved C / C++ / MFC
graphicswinformshelptutorial
10 Posts 4 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.
  • R Offline
    R Offline
    rjkg
    wrote on last edited by
    #1

    I have a 32bit bitmap with alpha channnel . I am drawing it using gdi+ . but I am not getting the transparency . How to get the transparency usnig gdi+

    Rajesh

    N J 2 Replies Last reply
    0
    • R rjkg

      I have a 32bit bitmap with alpha channnel . I am drawing it using gdi+ . but I am not getting the transparency . How to get the transparency usnig gdi+

      Rajesh

      N Offline
      N Offline
      Niklas L
      wrote on last edited by
      #2

      How are you drawing it? Do you have any code you can share? (small piece)

      home

      R 1 Reply Last reply
      0
      • N Niklas L

        How are you drawing it? Do you have any code you can share? (small piece)

        home

        R Offline
        R Offline
        rjkg
        wrote on last edited by
        #3

        Graphics graphics(hdc);//Handle to the device context //Load the image from a file Image image(L"test.bmp",FALSE); // test.bmp is 32bit with alpha channels for transparency graphics.DrawImage(&image,0,0,image.GetWidth(),image.GetHeight());

        Rajesh

        S 1 Reply Last reply
        0
        • R rjkg

          Graphics graphics(hdc);//Handle to the device context //Load the image from a file Image image(L"test.bmp",FALSE); // test.bmp is 32bit with alpha channels for transparency graphics.DrawImage(&image,0,0,image.GetWidth(),image.GetHeight());

          Rajesh

          S Offline
          S Offline
          S p k 521
          wrote on last edited by
          #4

          You have to specify Colormatrix and load it via ImageAttributes' SetColorMatrix() before using DrawImage() Regards, Spk

          R 1 Reply Last reply
          0
          • S S p k 521

            You have to specify Colormatrix and load it via ImageAttributes' SetColorMatrix() before using DrawImage() Regards, Spk

            R Offline
            R Offline
            rjkg
            wrote on last edited by
            #5

            What will be color matrix values ???

            Rajesh

            S 1 Reply Last reply
            0
            • R rjkg

              What will be color matrix values ???

              Rajesh

              S Offline
              S Offline
              S p k 521
              wrote on last edited by
              #6

              Thats based upon your requirement... if you need to convert 80% of the bitmap alpha values use this sample one... ColorMatrix colorMatrix = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; ImageAttributes imageAtt; imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap); Regards, Spk

              R 1 Reply Last reply
              0
              • S S p k 521

                Thats based upon your requirement... if you need to convert 80% of the bitmap alpha values use this sample one... ColorMatrix colorMatrix = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; ImageAttributes imageAtt; imageAtt.SetColorMatrix(&colorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap); Regards, Spk

                R Offline
                R Offline
                rjkg
                wrote on last edited by
                #7

                you understand wrong . I have 32bit bmp and talking about the alpha channel tranparency . not opacity of image .

                Rajesh

                modified on Friday, July 23, 2010 7:50 AM

                1 Reply Last reply
                0
                • R rjkg

                  I have a 32bit bitmap with alpha channnel . I am drawing it using gdi+ . but I am not getting the transparency . How to get the transparency usnig gdi+

                  Rajesh

                  J Offline
                  J Offline
                  Joe Woodbury
                  wrote on last edited by
                  #8

                  If you call GetPixelFormat() on a 32-bit bitmap (.bmp) loaded with Image, it will return PixelFormat32bppRGB. I've found that using PNG images works.

                  R 1 Reply Last reply
                  0
                  • J Joe Woodbury

                    If you call GetPixelFormat() on a 32-bit bitmap (.bmp) loaded with Image, it will return PixelFormat32bppRGB. I've found that using PNG images works.

                    R Offline
                    R Offline
                    rjkg
                    wrote on last edited by
                    #9

                    Can you share with some piece of code for help me

                    Rajesh

                    J 1 Reply Last reply
                    0
                    • R rjkg

                      Can you share with some piece of code for help me

                      Rajesh

                      J Offline
                      J Offline
                      Joe Woodbury
                      wrote on last edited by
                      #10

                      It's exactly the same, just load a .PNG file that has an alpha channel.

                      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