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. The Lounge
  3. Paint Program with Alpha Channel Support

Paint Program with Alpha Channel Support

Scheduled Pinned Locked Moved The Lounge
questioncareer
13 Posts 5 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.
  • B Offline
    B Offline
    Bletch
    wrote on last edited by
    #1

    I'm trying to edit some bitmaps with an alpha channel for a toolbar, and I need a program like Paint that comes with windows, but with support for an Alpha channel. I have downloaded several programs and checked them out, including Paint Shop Pro, and none will do the job so far. PSP doesn't seem to import/export the alpha channel of a simple .bmp file properly. Does anyone here have a program to suggest - I don't need any fancy features, just basic pixel editing and alpha... Ideas?

    C B 2 Replies Last reply
    0
    • B Bletch

      I'm trying to edit some bitmaps with an alpha channel for a toolbar, and I need a program like Paint that comes with windows, but with support for an Alpha channel. I have downloaded several programs and checked them out, including Paint Shop Pro, and none will do the job so far. PSP doesn't seem to import/export the alpha channel of a simple .bmp file properly. Does anyone here have a program to suggest - I don't need any fancy features, just basic pixel editing and alpha... Ideas?

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      AFAIK, BMP does not have official per-pixel alpha support. the 4th byte in a 32-bit BMP is "not used" according to MS's documentation for all versions of the BITMAPINFOHEADER. maybe MS is trying to sneak alpha into that 4th BYTE, but they're fighting against at least a decade of their own documentation that says it's "not used". a better bet would be to use PNG, TGA or TIFF which are at least intended to have true alpha channels. you're more likely to find real alpha support for those formats. Photoshop 6 has spotty alpha support for these, i hear v7 is better. -c

      Chris Losinger
      Smaller Animals Software

      B 1 Reply Last reply
      0
      • C Chris Losinger

        AFAIK, BMP does not have official per-pixel alpha support. the 4th byte in a 32-bit BMP is "not used" according to MS's documentation for all versions of the BITMAPINFOHEADER. maybe MS is trying to sneak alpha into that 4th BYTE, but they're fighting against at least a decade of their own documentation that says it's "not used". a better bet would be to use PNG, TGA or TIFF which are at least intended to have true alpha channels. you're more likely to find real alpha support for those formats. Photoshop 6 has spotty alpha support for these, i hear v7 is better. -c

        Chris Losinger
        Smaller Animals Software

        B Offline
        B Offline
        Bletch
        wrote on last edited by
        #3

        The system provided toolbar images in XP common controls library definitely include an alpha channel, and the toolbars appear to be using the data. I need to rearrange some of the images in these bitmaps, but can't do it because every program I've found strips the alpha information, thereby destroying the mask. I don't really want to get involved in trying to use a different image format just for a toolbar bitmap.

        P C B 3 Replies Last reply
        0
        • B Bletch

          The system provided toolbar images in XP common controls library definitely include an alpha channel, and the toolbars appear to be using the data. I need to rearrange some of the images in these bitmaps, but can't do it because every program I've found strips the alpha information, thereby destroying the mask. I don't really want to get involved in trying to use a different image format just for a toolbar bitmap.

          P Offline
          P Offline
          Paul Watson
          wrote on last edited by
          #4

          Bletch wrote: The system provided toolbar images in XP common controls library definitely include an alpha channel, and the toolbars appear to be using the data I have not checked but are you sure those are not GIF or ICO files? Windows Bitmaps definitley do not support an alpha channel.

          Paul Watson
          Bluegrass
          Cape Town, South Africa

          brianwelsch wrote: I find my day goes by more smoothly if I never question other peoples fantasies. My own disturb me enough.

          B 1 Reply Last reply
          0
          • B Bletch

            The system provided toolbar images in XP common controls library definitely include an alpha channel, and the toolbars appear to be using the data. I need to rearrange some of the images in these bitmaps, but can't do it because every program I've found strips the alpha information, thereby destroying the mask. I don't really want to get involved in trying to use a different image format just for a toolbar bitmap.

            C Offline
            C Offline
            Chris Losinger
            wrote on last edited by
            #5

            yes, and you can use 32-bit DIBs with alpha info in some newer GDI and GDI+ calls. but, like I said, the MS documentation doesn't say that BMP supports per-pixel alpha - at least none that i've seen. and, i suspect that's why you'll have a hard time finding an editor with alpha support for BMP. -c

            Chris Losinger
            Smaller Animals Software

            T B 2 Replies Last reply
            0
            • C Chris Losinger

              yes, and you can use 32-bit DIBs with alpha info in some newer GDI and GDI+ calls. but, like I said, the MS documentation doesn't say that BMP supports per-pixel alpha - at least none that i've seen. and, i suspect that's why you'll have a hard time finding an editor with alpha support for BMP. -c

              Chris Losinger
              Smaller Animals Software

              T Offline
              T Offline
              Todd Smith
              wrote on last edited by
              #6

              In a 4bit (16 color) to 8bit (256 color) BMP image the last entry int the pallete is used as the background color which becomes transparent. Typically in a 24bit image the first pixel is used as the transparent pixel. Todd Smith

              C 1 Reply Last reply
              0
              • C Chris Losinger

                yes, and you can use 32-bit DIBs with alpha info in some newer GDI and GDI+ calls. but, like I said, the MS documentation doesn't say that BMP supports per-pixel alpha - at least none that i've seen. and, i suspect that's why you'll have a hard time finding an editor with alpha support for BMP. -c

                Chris Losinger
                Smaller Animals Software

                B Offline
                B Offline
                Bletch
                wrote on last edited by
                #7

                Here are the first few bytes of the file, labeled with the names from MSDN, and the actual decimal value on the right. Note that the file is definitely a bitmap, and it is 32 bits (24 bits + alpha). bfType - 42 4D - "BM" bfSize - 36 BC 00 00 - 0x0000BC36 bfReserved1 - 00 00 - 0 bfReserved2 - 00 00 - 0 bfOffBits - 36 00 00 00 - 0x36 biSize - 28 00 00 00 - 0x28 biWidth - F0 02 00 00 - 752 bcHeight - 10 00 00 00 - 16 biPlanes - 01 00 - 1 biBitCount - 20 00 - 32 I didn't include it here, but the specified compression is 0 for none, so I'm not being confused by compressed data. The extra 8 bits are not just filler, either - here is a section of actual bitmap data further in the file (note that data is being provided for all 4 components): C3 FF 9E 9E pixel 9E EF 91 72 pixel 72 CF C5 AC pixel AC FF B5 B5 pixel Anyone who wishes to take a look, this from bitmap id 216 in the XP comctl32.dll version 6.0.2600.0

                C 1 Reply Last reply
                0
                • P Paul Watson

                  Bletch wrote: The system provided toolbar images in XP common controls library definitely include an alpha channel, and the toolbars appear to be using the data I have not checked but are you sure those are not GIF or ICO files? Windows Bitmaps definitley do not support an alpha channel.

                  Paul Watson
                  Bluegrass
                  Cape Town, South Africa

                  brianwelsch wrote: I find my day goes by more smoothly if I never question other peoples fantasies. My own disturb me enough.

                  B Offline
                  B Offline
                  Bletch
                  wrote on last edited by
                  #8

                  The file was originally a bitmap resource in a dll, and the first two bytes of the file are 'BM'. I show a more complete dump of the file below in my reply to Chris.

                  1 Reply Last reply
                  0
                  • B Bletch

                    I'm trying to edit some bitmaps with an alpha channel for a toolbar, and I need a program like Paint that comes with windows, but with support for an Alpha channel. I have downloaded several programs and checked them out, including Paint Shop Pro, and none will do the job so far. PSP doesn't seem to import/export the alpha channel of a simple .bmp file properly. Does anyone here have a program to suggest - I don't need any fancy features, just basic pixel editing and alpha... Ideas?

                    B Offline
                    B Offline
                    Bletch
                    wrote on last edited by
                    #9

                    I finally found one program that can do the job - Adobe Photoshop. Unfortunately, for my purposes its kind of like using a nuclear reactor to fry an egg, but at least it gets the job done. To answer some of the replies above, Photoshop opens the bitmap and does show alpha channel information for the image, and the best part is it allows the image to be saved as a bitmap with alpha channel intact.

                    1 Reply Last reply
                    0
                    • B Bletch

                      Here are the first few bytes of the file, labeled with the names from MSDN, and the actual decimal value on the right. Note that the file is definitely a bitmap, and it is 32 bits (24 bits + alpha). bfType - 42 4D - "BM" bfSize - 36 BC 00 00 - 0x0000BC36 bfReserved1 - 00 00 - 0 bfReserved2 - 00 00 - 0 bfOffBits - 36 00 00 00 - 0x36 biSize - 28 00 00 00 - 0x28 biWidth - F0 02 00 00 - 752 bcHeight - 10 00 00 00 - 16 biPlanes - 01 00 - 1 biBitCount - 20 00 - 32 I didn't include it here, but the specified compression is 0 for none, so I'm not being confused by compressed data. The extra 8 bits are not just filler, either - here is a section of actual bitmap data further in the file (note that data is being provided for all 4 components): C3 FF 9E 9E pixel 9E EF 91 72 pixel 72 CF C5 AC pixel AC FF B5 B5 pixel Anyone who wishes to take a look, this from bitmap id 216 in the XP comctl32.dll version 6.0.2600.0

                      C Offline
                      C Offline
                      Chris Losinger
                      wrote on last edited by
                      #10

                      yup. i'm not saying you can't store alpha the data in a BMP file, in fact i do it in my own stuff, as well as using the 4th palette BYTE as a way to store and transmit per-pixel alpha info in colormapped images, but i never claim it's a standard or accepted thing to do. it's simply not an officially documented way to use a BMP file. look at the help for any of the BITMAPINFOHEADER flavors: 32: The bitmap has a maximum of 2^32 colors. If the biCompression member of the BITMAPINFOHEADER is BI_RGB, the bmiColors member is NULL. Each DWORD in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The high byte in each DWORD is not used.... that's why support for this is spotty. on the other hand, PNG, TIFF, TGA, etc. all have official alpha channel support, etc.. -c

                      Chris Losinger
                      Smaller Animals Software

                      B 1 Reply Last reply
                      0
                      • T Todd Smith

                        In a 4bit (16 color) to 8bit (256 color) BMP image the last entry int the pallete is used as the background color which becomes transparent. Typically in a 24bit image the first pixel is used as the transparent pixel. Todd Smith

                        C Offline
                        C Offline
                        Chris Losinger
                        wrote on last edited by
                        #11

                        Todd Smith wrote: In a 4bit (16 color) to 8bit (256 color) BMP image the last entry int the pallete is used as the background color which becomes transparent. yes, it can be used for that. it could also be used to hold any data at all. however, the docs for RGBQUAD clearly state: rgbReserved : Reserved; must be zero. Todd Smith wrote: Typically in a 24bit image the first pixel is used as the transparent pixel. that's a context-specific way of handling it. no paint program would ever do that. -c

                        Chris Losinger
                        Smaller Animals Software

                        1 Reply Last reply
                        0
                        • C Chris Losinger

                          yup. i'm not saying you can't store alpha the data in a BMP file, in fact i do it in my own stuff, as well as using the 4th palette BYTE as a way to store and transmit per-pixel alpha info in colormapped images, but i never claim it's a standard or accepted thing to do. it's simply not an officially documented way to use a BMP file. look at the help for any of the BITMAPINFOHEADER flavors: 32: The bitmap has a maximum of 2^32 colors. If the biCompression member of the BITMAPINFOHEADER is BI_RGB, the bmiColors member is NULL. Each DWORD in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The high byte in each DWORD is not used.... that's why support for this is spotty. on the other hand, PNG, TIFF, TGA, etc. all have official alpha channel support, etc.. -c

                          Chris Losinger
                          Smaller Animals Software

                          B Offline
                          B Offline
                          Bletch
                          wrote on last edited by
                          #12

                          Point taken - your right about the docs. Apparently, however, in XP Microsoft has started using an alpha channel, but the docs aren't up to date as usual. They're actually using alpha channels a fair bit in XP, between toolbar images and icons (which are just a different flavor of bmp).

                          1 Reply Last reply
                          0
                          • B Bletch

                            The system provided toolbar images in XP common controls library definitely include an alpha channel, and the toolbars appear to be using the data. I need to rearrange some of the images in these bitmaps, but can't do it because every program I've found strips the alpha information, thereby destroying the mask. I don't really want to get involved in trying to use a different image format just for a toolbar bitmap.

                            B Offline
                            B Offline
                            Brit
                            wrote on last edited by
                            #13

                            Generally, when BMP files are used for RGBA (red, green, blue, alpha) images, they include the alpha information in a separate file. This might be whats going on in the "system provided toolbar images". Bletch wrote: I need to rearrange some of the images in these bitmaps, but can't do it because every program I've found strips the alpha information, thereby destroying the mask. Are you sure the paint program is stripping the Alpha information, as opposed to the other possibility that you are opening the RGB bitmap and not realizing that the Alpha bitmap is in another file? ------------------------------------------ "What happened in that Rhode Island club is shocking. To think that over a hundred people would attend a Great White concert." - The Onion

                            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