Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Standard format for an 8-bit palette.

This thread is locked; no one can reply to it. rss feed Print
Standard format for an 8-bit palette.
Andrei Ellman
Member #3,434
April 2003

Hi,

I'm wondering is there is a standard format for storing just a 256 colour palette. Attatched is an example of what JASC Paint Shop Pro 7 uses. Is this particular format common? Is it supported by other paint-programs (eg. Photoshop).

I am writing a program that reads and writes palettes, so I would like to use some form of standardised palette-format.

AE.

--
Don't let the illegitimates turn you into carbon.

Thomas Harte
Member #33
April 2000
avatar

I don't think there is a standard, other than doing something like saving a 1x1 8bpp BMP purely for the sake of preserving the palette. However that JASC file you supply does look identical to those produced by version 5.0 so it is almost certainly an internal JASC standard.

Tobias Dammers
Member #2,604
August 2002
avatar

The 1x1 BMP or PCX seems to be very common. JASC is the company that made Paint Shop Pro (at least the first few versions), and I haven't seen it in any other program yet. It is plain ascii though; the first line is sort of a header (it says something like "JASC PAL"), then (IIRC) comes a line that contains the number of entries (in ascii), then for each entry, one line with three numbers (ranging 0 to 255), again in ascii, separated with spaces. Should be easy to parse, but why bother? The BMP is probably even smaller anyway (since JASC needs up to 12 bytes to store a single palette entry, while 3 should be enough).
Another option, if you're using allegro datafiles anyway, is to store it there. Grabber can create a palette object from an 8bpp bitmap and store it separately.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Evert
Member #794
November 2000
avatar

I think (not sure) that Allegro can read palettes in that format. It's also very similar to NeoPaint palette files (the first few lines are different, but that's it).

Tobias Dammers
Member #2,604
August 2002
avatar

Last time I checked, allegro couldn't. Shouldn't be too hard to make a custom parser though.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

lennaert van der linden
Member #6,053
July 2005
avatar

the GIMP has a palette file format as well.

Sirocco
Member #88
April 2000
avatar

There is no standard format, although programs like Animator have their own custom formats.

The easiest way: a 768 byte file containing one byte for each of the R,G,B values of each color (3 bytes x 256 entries = 768 bytes).

Edit:

This is, IIRC, the same as Autodesk Animator's .COL format.

-->
Graphic file formats used to fascinate me, but now I find them rather satanic.

Andrei Ellman
Member #3,434
April 2003

AFAIK, Allegro does not have any means of reading in a palette directly (unless it's from an image-file). Also because Allegro stores palettes in 6-bit per component format instead of 8-bit, the lower two bits are lost when reading in the palette of an 8-bit palette-file.

It seems like there is no standardised format for storing a palette, so I'll have to try and support as many palette-formats as I can get my hands on. What format do GIMP palettes use? Does Photoshop have a file-format for palettes as well? Is there documentation for all known palette-file formats?

AE.

--
Don't let the illegitimates turn you into carbon.

Sirocco
Member #88
April 2000
avatar

The good news is that palettes are ridiculously simple chunks of data, so there's little reason to get all exotic about storing the data. Just from my personal experience, I've never run across a program that could read another program's palette file.

Edit:

Here's a link to a doc explaining the Autodesk Animator COL format.

-->
Graphic file formats used to fascinate me, but now I find them rather satanic.

Richard Phipps
Member #1,632
November 2001
avatar

I agree. I think saving as a window BMP or a GIF (even if just in the clipboard) is probably the best option.

Neil Walker
Member #210
April 2000
avatar

When you add a bitmap to a dat file, allegro strips out the palette, so it must know the format?

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Andrei Ellman
Member #3,434
April 2003

Sirocco said:

Just from my personal experience, I've never run across a program that could read another program's palette file.

It looks like I'll have to try and support as many palette file-formats that I can get my hands on.

Sirocco said:

Here's a link [pipin.tmd.ns.ac.yu] to a doc explaining the Autodesk Animator COL format.

Thanks. That will come in handy... Just had a brief look. It looks straightforward and sensible enough. Now if only every paint-program would support that format. Does anyone have a link to the docs for the GIMP or Photoshop palette-file formats?

[edit: Found one for Photoshop (5.0) here. Other palette file-format documantation would still be useful.]

Neil Walker said:

When you add a bitmap to a dat file, allegro strips out the palette, so it must know the format?

Allegro can read the palette, but when it does so, it strips off the bottom two bits in order to convert to a 6-bit colour-format. But what I'm trying to do here is to support palette-files.

AE.

--
Don't let the illegitimates turn you into carbon.

Go to: