PCX Conversion

Puppeteer

Emperor
Joined
Oct 4, 2003
Messages
1,687
Location
Silverdale, WA, USA
The hardest part of editing files seems to be converting to and from the indexed PCX file. I'm not a modder in the way most of the others here are; I dabble in programming not graphics, so I've done very little graphics modding: just some smiley popHeads retreads. But I do understand (mostly) the indexed palette situation.

While messing around with Otda3 and Godot I'm wondering if the PCX conversion can be better automated. Tell me if something like this makes sense or would be useful: A utility that could
  • Convert a PCX file into a 4-layered TIFF (or other simple layered format)
  • Convert a 4-layered TIFF to PCX, with Civ3-correct palette
The layers would be:
  • Civ colors. This might be an actual colored overlay, or it might be a map of which underlying pixels should be considered civ-colored
  • 24-bit color base graphic
  • Smoke/fog
  • Shadow
When converting to PCX, the civ-color, smoke, and shadow layers would internally mask/blank the base graphic so that an optimized 160-color (or whichever is appropriate) palette is generated. Then it ensures the rest of the palette is properly ordered based on relative intensity or grayscale values and builds the indexed PCX file.

It would seem to help automate the to/from palette problem, but you'd still have the intermediate TIFF format, so I'm not sure it's an improvement over current methods.
 
I'm not quite sure what you have in mind to do with the layers without a specific example. You mention smoke & shadow - these are sections of the palette reserved in the unit flics, which are not pcx. The pcx format is used for things such as the civilopedia icons, terrain graphics and so on - static images. Unit files have a completely different set of palette requirements and are saved in a different format. Someone experienced with unit files would have to address your suggestion, if those are the type of images you meant. I'd recommend looking at the various posts and tutorials Vuldacon has written up about creating unit files for a start. My response here is solely with regards to working with pcx.

Fundamentally, converting images to Civ-ready pcx is about the number of colors in the indexed palette. You haven't specified what mode the tiff file you're working with would be. The palette/index required by C3 is 256 colors. In 12 years of working with pcx I've found that the simplest way to get good results is to edit the image in RGB mode - millions of colors, not indexed - then convert to a palette indexed with 256 colors. Any format that can be converted to pcx by whatever graphics editing programs you prefer using is fine for saving the image during intermediate stages of the editing process.

Working with layers to edit individual parts of the image can be useful in some situations - such as assembling parts taken from different images, or carefully changing colors in one section of the image - but is not necessary. At some point in the process the layers would need to be merged - prior to conversion to a properly indexed pcx. From that point of view it doesn't matter whether or not layers were used during the editing. It's a matter of converting/exporting/saving a one layer image to pcx format.

Short version
: from my point of view - based on many years of experience - what you describe might be successful but seems unnecessarily complicated. Changing modes to RGB if the image is not already in that format, editing the image & saving in another format if desired, and changing modes to 256 colors / indexing once the image is satisfactory is much simpler.

As an addendum - it's even simpler if all you want to do is change colors in pre-existing pcx. Don't even have to change modes. It can be done simply by editing the colors within the existing palette.
 
I find that the hardest thing about converting from RGB to Indexed (256 colours) is if the RGB picture is using to wide a spectrum of colours the results are less favourable.

The best results are with pictures that are mostly grouped at one end of the spectrum or the other. (red orange yellow) or (green blue violet).

And avoid busy skies like twilight or cloudy, clear blue skies give far better results.

You can't add smoke at the indexed PCX level, add them at the RGB level, indexing is always the last step.
 
To add a bit to the very good responses already here, and from a PCX-centric perspective as that's all that I have worked with.

Depending on the PCX, Civ Color may play a role. Not for terrains, but for unit PCXs, for example. In these cases you generally want to convert to 254 colors, IIRC, saving the last two for transparency and Civ color. As I recall the guide I followed to learn how to work with this, and add those last two colors, was written by Kyriakos, targeting GIMP 2.4, and the screenshots were in Greek (but still perfectly follow-able to a non-Greek speaker if you use GIMP 2.4; unfortunately 2.6 changed the menu layout), and is in the Tutorials and Guides section here.

The other area where Civ Colors interact with PCXs are the ntp##.pcx files, which specify the actual civ colors for each civ, for a very wide variety of items. Rhye wrote a tutorial on this and posted it here on April 19, 2004. It's well worth a read if you're trying to match the Civ Color graphics precisely. I used it as my reference when adding the "Edit Civ Colors" feature to my editor (and putting a link to it there is how I was able to find it again today). The following screenshot shows a sample (though by no means all) of the Civ Color related things that these files control:



So if you decide to precisely match Civ Colors, give Rhye's guide a read!
 
Top Bottom