views:

274

answers:

4

Hello,

I know that the 12 bit RGB color pallette format , has 4 bit for each color R,G,B. But how is the structure of the raw data i.e.

1.) Does each color have a byte corresponding to it which in turn has 4 padding bits , and 4 data bits for color data

or

2.) Its a packed format , i.e. Byte-1= (padding bits + 4-Rbits) Byte-2 = (4-Gbits+4Bits)

How is the packing done?

Thank You.

-AD

+1  A: 

Where?

In memory, it can be anything---most likely it could be held in a 3-char array or struct...

In disk, since space is such a big deal, it'd likely be held in an even tighter format: 3 bytes representing two adjacent pixels: [RG][BR][GB], and packed/unpacked on write/read.

Still, it all depends on the specs of your format/platform.

Tordek
+1  A: 

Are you using a specific library or bit of hardware? It's likely that whatever you're interfacing with will set this information. Can you give us any more clues?

Jon Cage
A: 

I know that the 12 bit RGB color pallette format , has 4 bit for each color R,G,B.

Are you sure it's a palette format?

Generally, a palette format is made up of two distinct parts: The palette itself and the image. The palette is a look-up table of colour values, the format of which is implementation specific. The image is then a list of index-values for the pallet.

Palette formats are normally used to save memory, or sometimes to do neon-style animation (like the Windows95 loading screen had that blue strip at the bottom: the image was written to the screen once, and then some of the colours in the palette were rotated every few ms).

RobM
A: 

On a CD+G, each twelve bit palette entry is stored using the six lsb's of two consecutive bytes; there is no wasted space because the upper two bits are used for storing timing information. I think the Amiga just used three of the four nybbles in a 16-bit word. I'm not sure what other formats you might be thinking of.

supercat