Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 5608 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Palette is used since dawn of time for gfx data storage.A palette is simply a table(in the most cases with 256 entries) where each entry is a RGB tripplet.8 bit paletted images contain and palette and after that follow the image data where each byte is index into the palette that shows which RGB tripple shoud be used.

"Tonight we strike,there is thunder in the sky,together we''ll fight,some of us will die,but they''ll always remember that we''ve made a stand and many will die by hand!" - ManOwaR

Share this post

Link to post
Share on other sites
Palettes are left over from a previous era, but still have their uses.

Early graphics cards could only use 16, 32, or 256 colors out of a larger palette. Amigas had 4096 colors (4 bit red, 4 bit green, 4 bits blue), VGA has 256K colors (666), these days palettes have 4 million colors (888).

On VGA you could use 256 of those 256K colors at once. The palette is just a set of 256 RGB values indicating which colors you want to use.

Why limit yourself to a subset of colors? RAM used to be very expensive, processors used to be much slower, and data busses could carry less data. In short, using 1 byte per pixel instead of 3 or 4 bytes per pixel made things fast enough to be usable, and cheap enough that the average person could afford it.

Their use these days is size and speed, just as it was before. If you have an image that uses 200 colors, why encode it as a 32bit image when you can encode it as 8 bit with a palette? It takes less space, is faster for the graphics card to fetch, and more of the image can fit in the graphics card''s texture cache, so you fetch less often.

Direct3D''s use of palettes is pretty limiting. You can only use one palette across all texture stages. Also, I''ve witnessed some flaky behaviour from either DX8.1, or nVidia''s drivers when using palettes. Swapping palettes too often would reboot the machine! Put in a Sleep(10) before changing palettes, and it renders fine, though not usable. For these reasons I limit my use of palettes to 8 bit grayscale, and/or 8 bit alpha images, and only when L8, and/or A8 formats are not available. I set the palette upon device creation and reset, and never worry about it again.

Share this post

Link to post
Share on other sites
Yup, as above.

Ice-T: I do suggest you get a good book on graphics programming. I've noticed you've asked some similar questions in other forums on this board. Such as "what are matrices used for in games". Are these questions in a school/college/uni test?, if so learn - don't cheat, if not, is there any particular reason for such abstract questions?

BTW: D3D's palette support is really just a reflection of what graphics hardware is exposing. At least two of the big 3 hardware vendors decided to DROP palette support a couple of chips ago. On their chips, any API that's promising support is emulating it with CPU surface reads and table lookups.

BTW2: The Amiga (ECS/OCS) had a maximum of 64 displayable on a normal surface (HAM wasn't "normal" in a sense that was usable for games), though the copper went a long way toward rectifying that by allowing the whole 64 to be redefined out of the 4096 for every scanline. [32 realistically - but half bright could still be considered distinct colour ]

[edited by - s1ca on August 6, 2003 7:49:21 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!