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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. BitBlt w/ ROP codes in GDI+

BitBlt w/ ROP codes in GDI+

Scheduled Pinned Locked Moved C / C++ / MFC
graphicswinformsadobejsonhelp
11 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.
  • F Force Code

    I learned graphics programming using win32 api and its possible my programming style is stuck in a different era, so could anyone tell me: To the best of my knowledge there is no BitBlt with raster operation (ROP) codes in GDI+. IOW, only using GDI+, you cannot combine a source and destination bitmap using a basic bitwise logical operator (for example AND) on the binary bits of the two bitmaps. If this is the case, is it because bitwise logical ops aren't really necessary? I know GDI+ has alpha and other things that GDI does not. Are ROP codes just irrelevant in graphics programming today? I find that hard to believe - Consider that with a windows icon, it will store a black and white mask to be used in masking the background. How is that mask accomplished behind the scenes except via BitBlt with ROP codes? My real reason for asking this is that I have recently been familiarizing myself with the flash/actionscript/flex environment for web development and you can do all sorts of complex graphical operations/masks with it. However in Actionscript as well, there is alpha blending and other things, but apparently no bitwise logical operations possible between bitmaps. Thanks for anyone who can clear this up for me.

    B Offline
    B Offline
    bob16972
    wrote on last edited by
    #2

    You can create a memDC, create a graphics object using the memDC, draw to the graphics object, let the graphics object fall out of scope, then bitblt the memDC all you want. There are many things to do in the middle of all that but it is possible indirectly if thats what you need. However, setting the ROP for line drawing in the DC, then creating the graphics object from the DC will not work for things like "Rubberbanding". To the best of my knowledge, you need to draw to the DC directly for things that use SetROP2()

    1 Reply Last reply
    0
    • F Force Code

      I learned graphics programming using win32 api and its possible my programming style is stuck in a different era, so could anyone tell me: To the best of my knowledge there is no BitBlt with raster operation (ROP) codes in GDI+. IOW, only using GDI+, you cannot combine a source and destination bitmap using a basic bitwise logical operator (for example AND) on the binary bits of the two bitmaps. If this is the case, is it because bitwise logical ops aren't really necessary? I know GDI+ has alpha and other things that GDI does not. Are ROP codes just irrelevant in graphics programming today? I find that hard to believe - Consider that with a windows icon, it will store a black and white mask to be used in masking the background. How is that mask accomplished behind the scenes except via BitBlt with ROP codes? My real reason for asking this is that I have recently been familiarizing myself with the flash/actionscript/flex environment for web development and you can do all sorts of complex graphical operations/masks with it. However in Actionscript as well, there is alpha blending and other things, but apparently no bitwise logical operations possible between bitmaps. Thanks for anyone who can clear this up for me.

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

      GDI+ extends GDI, it doesn't replace it.  You're free to use GDI if you need the ROPs.

      Force Code wrote:

      Consider that with a windows icon, it will store a black and white mask to be used in masking the background. How is that mask accomplished behind the scenes except via BitBlt with ROP codes?

      Do you mean with GDI+?  I believe when you load an icon into a GDI+ Image/Bitmap it is converted to 32-bit ARGB so it uses alpha blending instead of the mask (based on experience, not documentation...try it :)). Mark

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

      F 1 Reply Last reply
      0
      • M Mark Salsbery

        GDI+ extends GDI, it doesn't replace it.  You're free to use GDI if you need the ROPs.

        Force Code wrote:

        Consider that with a windows icon, it will store a black and white mask to be used in masking the background. How is that mask accomplished behind the scenes except via BitBlt with ROP codes?

        Do you mean with GDI+?  I believe when you load an icon into a GDI+ Image/Bitmap it is converted to 32-bit ARGB so it uses alpha blending instead of the mask (based on experience, not documentation...try it :)). Mark

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

        F Offline
        F Offline
        Force Code
        wrote on last edited by
        #4

        Mark Salsbery wrote:

        Force Code wrote: Consider that with a windows icon, it will store a black and white mask to be used in masking the background. How is that mask accomplished behind the scenes except via BitBlt with ROP codes? Do you mean with GDI+? I believe when you load an icon into a GDI+ Image/Bitmap it is converted to 32-bit ARGB so it uses alpha blending instead of the mask (based on experience, not documentation...try it ). Mark

        So everything that can be accomplished with ROP codes can be done w/ alpha blending? I know what alpha blending is, and used it in an application I'm developing, but the concept of it as a complete replacement for bitwise logical ops on bitmaps is new to me. Would someone attempt to do away with C's bitwise operators - and then replace it with what? I don't get it. How would you replace the ROP code 0x00AC0744 (which I actually use somewhere). How do you replace SRCAND or SRCPAINT, for that matter. I guess I need to find out however, because none of the modern programming environments seem to have anything but alpha. Don't suppose you know of a primer that would get me up to speed. (Well, it looks like you implied above that rop codes are still needed - still slightly confused - why wouldn't actionscript have either bitwise AND or OR for bitmaps given all the myriad stuff it can do.)

        L M 2 Replies Last reply
        0
        • F Force Code

          Mark Salsbery wrote:

          Force Code wrote: Consider that with a windows icon, it will store a black and white mask to be used in masking the background. How is that mask accomplished behind the scenes except via BitBlt with ROP codes? Do you mean with GDI+? I believe when you load an icon into a GDI+ Image/Bitmap it is converted to 32-bit ARGB so it uses alpha blending instead of the mask (based on experience, not documentation...try it ). Mark

          So everything that can be accomplished with ROP codes can be done w/ alpha blending? I know what alpha blending is, and used it in an application I'm developing, but the concept of it as a complete replacement for bitwise logical ops on bitmaps is new to me. Would someone attempt to do away with C's bitwise operators - and then replace it with what? I don't get it. How would you replace the ROP code 0x00AC0744 (which I actually use somewhere). How do you replace SRCAND or SRCPAINT, for that matter. I guess I need to find out however, because none of the modern programming environments seem to have anything but alpha. Don't suppose you know of a primer that would get me up to speed. (Well, it looks like you implied above that rop codes are still needed - still slightly confused - why wouldn't actionscript have either bitwise AND or OR for bitmaps given all the myriad stuff it can do.)

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #5

          Force Code wrote:

          but the concept of it as a complete replacement for bitwise logical ops on bitmaps is new to me.

          Isn't it only partial. I'm not versed in graphics by any measure but doesn't GDI+ cover everything by providing DrawImage (which you can use multiple times) with Effects objects and ImageAttributes?

          F 1 Reply Last reply
          0
          • F Force Code

            Mark Salsbery wrote:

            Force Code wrote: Consider that with a windows icon, it will store a black and white mask to be used in masking the background. How is that mask accomplished behind the scenes except via BitBlt with ROP codes? Do you mean with GDI+? I believe when you load an icon into a GDI+ Image/Bitmap it is converted to 32-bit ARGB so it uses alpha blending instead of the mask (based on experience, not documentation...try it ). Mark

            So everything that can be accomplished with ROP codes can be done w/ alpha blending? I know what alpha blending is, and used it in an application I'm developing, but the concept of it as a complete replacement for bitwise logical ops on bitmaps is new to me. Would someone attempt to do away with C's bitwise operators - and then replace it with what? I don't get it. How would you replace the ROP code 0x00AC0744 (which I actually use somewhere). How do you replace SRCAND or SRCPAINT, for that matter. I guess I need to find out however, because none of the modern programming environments seem to have anything but alpha. Don't suppose you know of a primer that would get me up to speed. (Well, it looks like you implied above that rop codes are still needed - still slightly confused - why wouldn't actionscript have either bitwise AND or OR for bitmaps given all the myriad stuff it can do.)

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

            Force Code wrote:

            So everything that can be accomplished with ROP codes can be done w/ alpha blending?

            I never stated that anywhere.  I attempted to answer a specific question - the one I quoted from your post.  If you weren't referring to GDI+ (which I asked), then you can disregard the comment. Again, if you want to use the ROP codes, use GDI.  There's nothing wrong with that....it's still fully supported. Mark

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

            F 1 Reply Last reply
            0
            • M Mark Salsbery

              Force Code wrote:

              So everything that can be accomplished with ROP codes can be done w/ alpha blending?

              I never stated that anywhere.  I attempted to answer a specific question - the one I quoted from your post.  If you weren't referring to GDI+ (which I asked), then you can disregard the comment. Again, if you want to use the ROP codes, use GDI.  There's nothing wrong with that....it's still fully supported. Mark

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

              F Offline
              F Offline
              Force Code
              wrote on last edited by
              #7

              Mark Salsbery wrote:

              Force Code wrote: Consider that with a windows icon, it will store a black and white mask to be used in masking the background. How is that mask accomplished behind the scenes except via BitBlt with ROP codes? Do you mean with GDI+? I believe when you load an icon into a GDI+ Image/Bitmap it is converted to 32-bit ARGB so it uses alpha blending instead of the mask (based on experience, not documentation...try it ). Mark

              Not sure what the mere fact its converted to ARGB indicates. It seems a bitblt could still be performed on the lower 24 bits. How would you make a bitmap background transparent only using the source, destination, and alpha blending (with no mask bitmap). OK I'll answer my own question, by using the alpha channel as the mask bitmap.

              M 1 Reply Last reply
              0
              • L led mike

                Force Code wrote:

                but the concept of it as a complete replacement for bitwise logical ops on bitmaps is new to me.

                Isn't it only partial. I'm not versed in graphics by any measure but doesn't GDI+ cover everything by providing DrawImage (which you can use multiple times) with Effects objects and ImageAttributes?

                F Offline
                F Offline
                Force Code
                wrote on last edited by
                #8

                Thanks i'll look into this

                1 Reply Last reply
                0
                • F Force Code

                  Mark Salsbery wrote:

                  Force Code wrote: Consider that with a windows icon, it will store a black and white mask to be used in masking the background. How is that mask accomplished behind the scenes except via BitBlt with ROP codes? Do you mean with GDI+? I believe when you load an icon into a GDI+ Image/Bitmap it is converted to 32-bit ARGB so it uses alpha blending instead of the mask (based on experience, not documentation...try it ). Mark

                  Not sure what the mere fact its converted to ARGB indicates. It seems a bitblt could still be performed on the lower 24 bits. How would you make a bitmap background transparent only using the source, destination, and alpha blending (with no mask bitmap). OK I'll answer my own question, by using the alpha channel as the mask bitmap.

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

                  Force Code wrote:

                  Not sure what the mere fact its converted to ARGB indicates.

                  Then I guess you weren't referring to GDI+, so you can disregard my comments about how icons are converted when brought into the GDI+ world.

                  Force Code wrote:

                  How would you make a bitmap background transparent only using the source, destination, and alpha blending (with no mask bitmap).

                  With GDI or GDI+?  With GDI+ I don't need to be concerned with the destination. All I need to be concerned with is the source bitmap and the Graphics object's compositing mode. Any pixel in the bitmap that has an alpha-channel value of 0 will be transparent. Mark

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

                  F 1 Reply Last reply
                  0
                  • M Mark Salsbery

                    Force Code wrote:

                    Not sure what the mere fact its converted to ARGB indicates.

                    Then I guess you weren't referring to GDI+, so you can disregard my comments about how icons are converted when brought into the GDI+ world.

                    Force Code wrote:

                    How would you make a bitmap background transparent only using the source, destination, and alpha blending (with no mask bitmap).

                    With GDI or GDI+?  With GDI+ I don't need to be concerned with the destination. All I need to be concerned with is the source bitmap and the Graphics object's compositing mode. Any pixel in the bitmap that has an alpha-channel value of 0 will be transparent. Mark

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

                    F Offline
                    F Offline
                    Force Code
                    wrote on last edited by
                    #10

                    Mark Salsbery wrote:

                    With GDI+ I don't need to be concerned with the destination. All I need to be concerned with is the source bitmap and the Graphics object's compositing mode.

                    Does "compositing mode" mean the alpha channel or something else?

                    M 1 Reply Last reply
                    0
                    • F Force Code

                      Mark Salsbery wrote:

                      With GDI+ I don't need to be concerned with the destination. All I need to be concerned with is the source bitmap and the Graphics object's compositing mode.

                      Does "compositing mode" mean the alpha channel or something else?

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

                      In a GDI+ Graphics object, the compositing mode determines how a source color is blended (composited) with a destination color. The alpha channel, if present, is used in both currently supported compositing modes. See  Graphics::SetCompositingMode[^] for more details. 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