Jump to content

CnCNet Forums

Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Nyerguds

[C&C1/RA1/TS/RA2] Editing paletted graphics in Gimp

Recommended Posts

Nowadays, it seems that the very concept of paletted graphics doesn't get much attention in image editors anymore. In fact, many people don't even grasp the concept of colour palettes anymore. So I've decided to write a tutorial explaining what paletted graphics are in general, how they work in the Command & Conquer games, and how to edit them with Gimp.

Gimp is probably not the ideal image editor to use for paletted graphics, but it does, in fact, support them (unlike programs like MS Paint), and it's free. It has its drawbacks, though. The relevant options are not always easy to find, and its brush tools have ridiculously large default sizes for pixel editing work, which are always reset on restart of the program.

 

Paletted graphics

Right. First of all, what are paletted graphics? I'm not really an expert on the history behind it all, but basically, they are a way to save memory.

In a normal, full-colour image, each pixel is assigned a colour. Such a colour is a triplet of bytes, each byte being one colour component. The three are Red, Green, and Blue. This means that each pixel on an image would take up three bytes. On modern image formats, a fourth is assigned for transparency, but that's irrelevant in C&C graphics, so we won't discuss that here.

Paletted graphics, in contrast, use only one byte per pixel (or less, but we'll stick to C&C's 8-bit-per-pixel images here for now). A paletted image's file header contains a list of 256 colour triplets which define all colours that will be used on the image. Once you got that palette, each actual pixel on the image simply needs to refer to a colour index on that palette; a number from 0 to 255, a value which fits inside a single byte. So at the extra cost of adding the palette in advance, the actual image can be a lot smaller in file size.

There's some historical reasons for this in the way graphics cards handle graphics using palettes, but since I don't really know the specifics of that, let's not go deeper into that.

Instead, let's look at a very peculiar kind of paletted image formats: game sprites.

What's so odd about game sprites, like the C&C SHP format, is that they are paletted images without colours saved inside them. Instead, they will use whatever colours the game (or an external viewing tool, like XCC Mixer) gives it. This explains why C&C1 graphics will work perfectly fine in RA1, but will look all messed up: the file format is the same, but the C&C graphics were made for a different palette, meaning the palette indices on these graphics are all wrong in RA1's colour palette.

So, you may wonder, why did Westwood not simply include the palette? There are two reasons for that.

The first: in C&C1 and RA1, the entire screen, at any given time, contains only a single palette. The game itself can only show graphics of one single 256-colour palette at the same time.

The second: Command & Conquer 1 uses the same unit and structure graphics for all theaters, while Desert theater has a different palette than Temperate/Winter. How is this done? Simple, actually: the palettes have parts that are different, and parts that are the same. The units, structures and general game UI are made so they ONLY use the palette indices on which the colours remain the same between all theaters.

In Tiberian Sun and Red Alert 2, they decided to keep the same 256-colour formats because of the ease of remapping the house colours on 256-colour graphics. The games themselves, though, are high colour, and can handle showing several colour paletted graphics with different palettes at the same time.

I hope this gives some insight into the game's graphics formats.

 

Usage in Gimp

(everything here was tested on Gimp 2.8.0)

From what I've seen, Gimp does not have any feature to import or export colour palettes in specific palette file formats. However, like any image editor that supports colour palettes, it can simply get the palette from the image itself.

First of all, to see the palette in a 256-colour image in Gimp, go to [Windows] -> [Dockable Dialogs] -> [Colormap]. This will give you a dialog on which you can see the current image's palette at all times.

You can click on the colours in this colour map dialog to easily select them for editing. Another handy feature for pixel work is to enable the grid in Gimp. You can find it under [View] -> [show Grid].

So, what we need to do to get the palettes into Gimp is simply convering some SHP file to PNG with XCC Mixer, with the palette we need, and then opening that in Gimp to get the palette out. For completeness' sake, I'll go over the steps including XCC Mixer:

  • In XCC Mixer, press ctrl+p, and select the palette you want to import into Gimp.
  • Right-click on any SHP file you want, and press [Copy As PNG].
  • If the conversion created multiple PNG images, delete all but one of them. It doesn't matter at all what is on the image; only the palette saved in its file header is important.
  • Open the remaining single image in Gimp.
  • In Gimp, go to [Windows] -> [Dockable Dialogs] -> [palettes]. This will give you the list of Gimp's internal colour palettes.
  • In that list, right click and select [import Palette]. It will open the "Import Palette" dialog.
  • On the dialog, change the radio button for the source selection to "Image", and select the image you opened as source to take the palette from.
  • At the bottom of the dialog, give the palette a name (easiest would be to use the same name as the one in XCC Mixer) and press [import]. The palette will now show up in Gimp's palettes list.

So, what can we do with these imported palettes? One of the uses is the palette conversion I covered in my other tutorial. Here's how to do that conversion in Gimp:

  • Open the image in Gimp.
  • Go to [image] -> [Mode]. You'll see the mode is either [RGB] or [indexed]. If it is already Indexed, change it to RGB.
  • Go to [image] -> [Mode] again, and now select [indexed]. A colour conversion dialog will appear.
  • In the dialog, select "use custom palette", select one of the palettes you imported before, UNCHECK "remove unused colours", set Dithering to 'None', and click [Convert].

That's it. Export the image as png or something again, and you're done.

Another possibility is to change an image's palette without adapting the graphics to the new palette. This is handy if you have graphics converted with the standard yellow remap, but you want to change them to the purple palettes as remap for editing.

To do such a palette replacement:

  • Go to [Colors] -> [Map] -> [set Color Map].
  • Click the palette button, select the new palette, and press [Close]
  • Press [OK].

That's it! You should now see the image adapt its colours to the new palette.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • By Tønnao
      Hi folks!
      I was wondering whether or not it's possible to AI upscale the cutscenes in Tiberian Sun and put them into the game?
      I am absolutely sure that the cutscene files "MOVIES01.MIX" and "MOVIES02.MIX" contains additional data in order for the cutscenes to load correctly and at the right moments, but does anyone of you know how to perhaps modify the files and extract stricly the cutscenes, in order to upscale them and put them back.
      Of course it wouldn't be anywhere near as great as a proper remaster, but more so just to give the cutscenes a facelift.
    • By Concolor1
      Hi, Ive a problem, Im looking at some old stuff. So I have FA2YR1.2 and I have the TX2. The TX 2 gives me the files marble.mix FAdata and FALanguague. Ive placed these into my Final AlertYR folder, overwriting the originals, (Don't worry I saved them first). However its still not reading, and the picture below is what im getting, what am I missing?
      Now if I place the lunarmd from the TX into the RA2 folder, it then reads the new Terrain, however although the dropdown list is there, the Terrain is still absent. Is this because the map was written with the TX 1, and the updated version has moved the list order?

    • By CykaRushB
      This issue appeared shortly after a windows 10 update. The current settings were working fine beforehand.
       
      When I start a match, the game shows up in the top left of my screen and covers only about 1/4 of the screen. I can still see the desktop in the background.
      Please see this video that shows the problem: 
       
       
       
    • By ajchvy
      Having an issue installing the RA2 CnCnet file. Keeps giving me this issue. If I hit ignore, it will install, but then game crashes when I try to start a match.
       

    • By mrmiclego
      Hey could anyone help me out? Im trying to get the YR CnCNet launcher working, but I keep getting this pop up (see the first uploaded image). I have ran it as an administrator and still nothing. Things to note about my game and setup:
      Windows 10 computer with Geforce RTX 2070, Driver version 461.92, and an Intel i7 Game Purchased off of Origin I deleted everything in _Installer/directx/redist except for DSETUP.dll, dsetup32.dll, and DXSETUP.exe to get the game to install properly File is set to Full Control Game launcher icon has the administrator icon on it already tried to load it with all anti-virus software offline I don't believe this could be a connection issue because Tiberian Sun CnCNet runs fine.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...