In fact, Spinning palette BMP is normal BMP picture resolution 320x400 pixels and 256 colors or color depth 8 bits per pixels. The difference between normal BMP and spinning palette BMP is only one byte. I want to show you the BMP file format first, before we will discuss about spinning palette BMP.
BMP file format
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Purpose of paletteIn order to reduce size of bitmap, we use palette to specify color of each pixels than by enumerate all intensity of red, green and blue color. The only used colors will be kept in color palette. And picture bitmap keep information of which color in palette each pixels use.
Example for picture belowThe colors would be kept are
|
![]() |
Deep into fileIf we save our example picture to BMP file. And use some kind of binary file viewer to look deep into this BMP. You should see....Spinning paletteLet's see the BMP file format again. First two bytes are BMP file signature "BM".
Next in offset 2 is size of this file = B8h.
Offset Ah keep information where is the bitmap pattern location, in this case = 5Eh.
Offset 12h and 16h are picture's width and height = 0Bh or 11x11 pixels.
Offset 1Ch indicate BPP of picture. In this case = 4 because number of color used in this picture is 10. Then the least number of bit that still give number of color much enough is 4 (2^4 = 16).
Offset 1Eh is 0 tell us this BMP has no compression.
Offset 22h should indicate size of bitmap but in this case it is 0. Don't worry there is no problem. It because of this field was neglected today by most of program include the program that generated this BMP.
Offset 2Eh tell the number of color used = Ah or 10. If this field is 0, it means picture uses full color set or uses all 2^BPP colors.
Offset 32h tell the number of important color. We will talk about this field later.
Offset 36h is start of color palette. Color palette size is 4*NCL = 40 bytes. So from offset 36h-5Dh is palette's area. It keeps color information in form "BGR_". As we can see above, first 4 bytes of palette's data are 00 00 FF 00 that means first color has B=0, G=0, R=255 and next 4 bytes of palette are 26 00 C4 00 that means next color has B=38, G=0, R=196 and so on.
And offset 5Eh is start of picture bitmap. Picture's data would be saved pixel by pixel from bottom to top, from left to right. Since BPP = 4 means 4 bits used for one pixel or data in bitmap one byte would contain 2 pixels. From figure above, byte stream of bitmap are99 55 55 55 55 50 90 09 95 55 55 57 77 70 99 55 95 44...... Interested point is after most right pixel of bottom line's data there are few unknown bytes appear before data of next line. 99 55 55 55 55 50 90 09 95 55 55 57 77 70 99 55 95 44...... Where are they come from?
The reason is Windows' bitmap was designed for be read or writed 32 bits (4 bytes) each time. So the dummy bytes were added for this activity.[99 55 55 55] [55 50 90 09] [95 55 55 57] [77 70 99 55] [95 44...... And the most interested point is how can we make spinning palette BMP. As we mention in above section about one field at offset 32h, the number of important color field. In past when computer display technology was not powerful as today. To display high quality color is almost impossible. Displaying resource must be most efficiently used. NIC field was used for this reason. But today, this field was useless. New function was assigned for this field by Windows 95. It is used to tell number on still color. Color under this number will still while color elswhere will spin.Relate files
In example, if we have picture's palette like this
![]()
If NIC is 0 means all colors would still.
If NIC is F0h means all colors under F0h would still while color F0h to FFh would spin like this.
![]()
That's all folk!. I have told you, it is only one byte differ from general BMP, offset 32h.
You can make your own spinning palette BMP just by modifying this NIC field.
EX.BMP : Example BMP picture.
HEXVIEW.ZIP : Binary file viewer. Another freeware from QTam software.
BMP.TXT : Quick reference for BMP file format.By Panya Thanyaprasertkul
Homepage http://www.geocities.com/SiliconValley/Campus/7779
Email khun_panya@yahoo.com