What`s a palette in the parsing a bitmap context
-
I`m learning how to work with bitmaps. Could someone explain what`s a palette when reading from a bitmap
-
I`m learning how to work with bitmaps. Could someone explain what`s a palette when reading from a bitmap
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."
-
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."
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?
-
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?
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."
-
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."
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.
-
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.
-
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."
thanks for your help. So biBitCount less than 9 it`s no longer what you would consider a bitmap
-
thanks for your help. So biBitCount less than 9 it`s no longer what you would consider a bitmap
-
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."
my bad, I meant it`s no longer a .bmp
-
my bad, I meant it`s no longer a .bmp
-
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."
I understand
-
I understand
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