0
votes

Background: I'm trying to look through assets in an old game's archive files. They're 8-bit. I need a palette for them to look correct.

  • I have the palette. DxWnd supports dumping the active palette.

  • However, the palette is in the form of a dialog with 16x16 colors (=256) stretched.

Original output

[updated to include actual output]

  • I then shrunk them to single pixels-per-color. So now I have a 16x16 (true color) bitmap.

I want to get a palette file from that. I don't know if there's a standard format for palettes, or it's just plain-old-data of (256*3 for RGB) bytes. GIMP supports a palette format that you can import when importing "raw image data".

So, the question is: What would be the easiest way to convert this 16x16 image of true-color values to a block of 3x256 bytes palette?

Whether it's tools, or Python, C/C++, or whatever. The point is, this is a minor issue ("wrong data format"). So if some existing tools (Linux or Windows) can use it, by all means.

To be absolutely clear: This isn't a sprite. It doesn't need to be heuristically converted to some "best fit" palette. It's literally the palette.

[edit] I tried, per the comments, to output the palette from GIMP and IrfanView, but I get this, jumbled set of colors instead:

Jumbled result after 8-bit conversion

1
Open it in IrfanView, reduce to 8-bit, export palette. Like you, I have no idea what format you're looking for but it might work.Retired Ninja
I've tried doing that with GIMP but the problem is (unexpectedly) that it won't produce the palette IN THE RIGHT ORDER! It jumbles everything around! I would have assumed it would find a free slot and if every element is unique, it'd just fill up "free slots" of the potential palette in order. But no. I'll try IrfanView just in case.Katastic Voyage
Ah, I see what you're saying. It seems like technically a 16x16 24-bit raw image is a palette. Each pixel is 3 color bytes, 256 pixels. It might work with just what you have if you save it as raw.Retired Ninja
FYI, I just tried IrfanView and the palette is still out of order. (going to update my post to show results)Katastic Voyage
You need to narrow the question by deciding on what you want to do and how you want to do it. The way Stack Overflow works is, you decide on a language and technique. You don't ask the community for a language like "Python, C/C++, or whatever".jww

1 Answers

0
votes

ImageMagick will give a raw, 256*24bit RGB image that GIMP can use as a palette when opening a raw image from your image like this:

convert UEw8E.png -resize '16x16!' -filter point -depth 8 palette.rgb

(The ! means to force the size, regardless of aspect ratio, needed as your image is not a square. -filter point skips downscale filters. -depth 8 forces 8 bits per colour. Although your image already is 8 bits per colour, it's good to know for certain which format it will output.)

The file created, palette.rgb, is a raw array of the 8 bit per colour (24-bit RGB) palette from your image, left to right, top to bottom. (which, I think you were asking for)

Now opening any raw image with GIMP (tested with 2.8.22), with the settings

  • Image Type: Indexed
  • Palette Type: R, G, B (normal)
  • Palette File: palette.rgb

The palette inside GIMP looks like this (everything is in the same order as in your image):
the palette inside GIMP