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. What`s a palette in the parsing a bitmap context

What`s a palette in the parsing a bitmap context

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsjsontutoriallearning
12 Posts 4 Posters 1 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
    Calin Negru
    wrote on last edited by
    #1

    I`m learning how to work with bitmaps. Could someone explain what`s a palette when reading from a bitmap

    P 1 Reply Last reply
    0
    • C Calin Negru

      I`m learning how to work with bitmaps. Could someone explain what`s a palette when reading from a bitmap

      P Offline
      P Offline
      phil o
      wrote on last edited by
      #2

      A palette is a collection of indexed colours. In a bitmap using a palette, instead of refering to a colour by specifying its raw value, it is specified by its index in the palette instead.

      "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

      C 1 Reply Last reply
      0
      • P phil o

        A palette is a collection of indexed colours. In a bitmap using a palette, instead of refering to a colour by specifying its raw value, it is specified by its index in the palette instead.

        "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

        C Offline
        C Offline
        Calin Negru
        wrote on last edited by
        #3

        Thanks phil.o, so this palette is used as a compression method/way to save space? Is this feature used at all? How do people usually store data to bmps with or without using a palette?

        P 1 Reply Last reply
        0
        • C Calin Negru

          Thanks phil.o, so this palette is used as a compression method/way to save space? Is this feature used at all? How do people usually store data to bmps with or without using a palette?

          P Offline
          P Offline
          phil o
          wrote on last edited by
          #4

          Exactly, this allows to save space by 1) only referencing used colours in the palette 2) using colour references instead of raw values. This feature is used in .gif files, as well as in icons, IIRC. It is not used in .bmp files, which store colour information uncompressed. It may be used in other formats as well.

          "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

          L 1 Reply Last reply
          0
          • P phil o

            Exactly, this allows to save space by 1) only referencing used colours in the palette 2) using colour references instead of raw values. This feature is used in .gif files, as well as in icons, IIRC. It is not used in .bmp files, which store colour information uncompressed. It may be used in other formats as well.

            "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Unfortunately (I would call it that, because it's a mess) BMP files are in theory quite general, with tons of annoying features being piled onto it. Using any of those features results in a BMP file that a lot of software can't read (or reads differently than intended) because almost everyone treats BMP as only 24bit-uncompressed with no fancy extras. But anyway, in theory, a BMP file can indicate that it has 8 or fewer bits per pixel and then it must have a color table aka palette. The pixel data can even be compressed then.

            P 1 Reply Last reply
            0
            • L Lost User

              Unfortunately (I would call it that, because it's a mess) BMP files are in theory quite general, with tons of annoying features being piled onto it. Using any of those features results in a BMP file that a lot of software can't read (or reads differently than intended) because almost everyone treats BMP as only 24bit-uncompressed with no fancy extras. But anyway, in theory, a BMP file can indicate that it has 8 or fewer bits per pixel and then it must have a color table aka palette. The pixel data can even be compressed then.

              P Offline
              P Offline
              phil o
              wrote on last edited by
              #6

              Thanks for the update. I never had to work with bmps other than plain 24 bpp (or 8 bpp for b/w) uncompressed data.

              "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

              C 1 Reply Last reply
              0
              • P phil o

                Thanks for the update. I never had to work with bmps other than plain 24 bpp (or 8 bpp for b/w) uncompressed data.

                "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

                C Offline
                C Offline
                Calin Negru
                wrote on last edited by
                #7

                thanks for your help. So biBitCount less than 9 it`s no longer what you would consider a bitmap

                P 1 Reply Last reply
                0
                • C Calin Negru

                  thanks for your help. So biBitCount less than 9 it`s no longer what you would consider a bitmap

                  P Offline
                  P Offline
                  phil o
                  wrote on last edited by
                  #8

                  Yes I would still consider it as a bitmap. I was specifically talking about .bmp files. The general notion of bitmap is something different.

                  "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

                  C 1 Reply Last reply
                  0
                  • P phil o

                    Yes I would still consider it as a bitmap. I was specifically talking about .bmp files. The general notion of bitmap is something different.

                    "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

                    C Offline
                    C Offline
                    Calin Negru
                    wrote on last edited by
                    #9

                    my bad, I meant it`s no longer a .bmp

                    P 1 Reply Last reply
                    0
                    • C Calin Negru

                      my bad, I meant it`s no longer a .bmp

                      P Offline
                      P Offline
                      phil o
                      wrote on last edited by
                      #10

                      But apparently I'd be wrong, as harold aptroot told, .bmp format is way more generic than that.

                      "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

                      C 1 Reply Last reply
                      0
                      • P phil o

                        But apparently I'd be wrong, as harold aptroot told, .bmp format is way more generic than that.

                        "Five fruits and vegetables a day? What a joke! Personally, after the third watermelon, I'm full."

                        C Offline
                        C Offline
                        Calin Negru
                        wrote on last edited by
                        #11

                        I understand

                        L 1 Reply Last reply
                        0
                        • C Calin Negru

                          I understand

                          L Offline
                          L Offline
                          leon de boer
                          wrote on last edited by
                          #12

                          It is rare but even 24bit and 32bit bitmaps can have palettes, you do it if you want something like millions of shades of blue for example when printing an ocean scene. If you look at the structure of the BitmapFileInfo header .. look at the second last entry that is how you know how many palette colours there are ... the last entry tells you how many are important. bitmapinfoheader[^] It is spelled out very clearly ...

                          If biClrUsed is zero, the array contains the maximum number of colors for the given bitdepth

                          You assume a 24bit or 32bit bitmap have no palette at your own risk.

                          In vino veritas

                          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