Advertisement

Question About Palettes

Started by December 16, 2002 11:41 AM
0 comments, last by bower12345 21 years, 11 months ago
Hey All, I just have a quick question about palettes. I''m still a little confused on them. I understand that they are a lookup table where colors are gotten from and I see that sometimes they must be used in programs that use less than 16-bit color. I also saw a code example that was getting palette information from the bitmap file header itself. Is there any way that anyone can possibly explain palettes a little more for me, show me some sample code of how to obtain/create pallettes, or point me to some other reference? Thanks! Mike
Mikehttp://cs.wpunj.edu/~bowersom
Well the basics here are:

A palette in bitmap terms is similar to what an actual painters palette is (you know the tray that that Bob guy on PBS has all the time when he paints pictures).

In effect the palette holds colors. In our case each palette item consists of 3 components Red, Green and Blue. Each component takes up 8 bits of data (Hence the term 8-Bit color). Now a palette like the one I''m talking about can 256 colors. Typically the color in the 0 slot (the first slot) is the color that is the transparent color by default.

Now, the trick about palettized images is that what ever is displayed on screen at the same time must all use the same palette or your images will come out looking very strange.

Palettes come in 2 forms. The palettes that are saved into a bitmap. This happens when you take an image in a program like paint and say "Save As 256 color bitmap". And ones that have been saved into a .pal file. This happens when you go into paint and save the palette out. The .pal file helps you unify all the palettes your images use so that you don''t get strange results when you blit your bitmaps on the screen.


Now when you load up everything onto the screen you should only need to load a single palette each level. The easiest way to do this is to use the LoadBitmap() function call built into win32, and get a handle to the bitmap as well as the palette. So I won''t get into that much as you can use http://msdn.microsoft.com to figure out how to do this.

As for loading a .pal file do a search on google.com you''ll find alot of instructions on how to do this.

This topic is closed to new replies.

Advertisement