• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

unmerged(29568)

Second Lieutenant
May 24, 2004
153
0
www.oswego.edu
Is it possible to actually change the counter graphic (the flag part), a number of messages have said no but a few have suggested its possible. I know you can play with the palette to change colors but I want to actually change the flag and wondering if this has ever been done.
 
Yes it is possible. All the flags are created off the same template of pixels each represented by a different colour on the colour pallette.

You should be able to modifiy the flag by opening the colour palette for the country in question, finding those pixels that represent the flag and changing them.
 
Can you be alittle more specific (what files exactly, etc), I am familar with palette files and such basically but from what I understand if I change the palette file all it would do is change one color in the counters to another versus being able to change the actual graphic on the counter.
 
Thats right... thats how the flags are formed, by manipulating the colours in the palette.

Each countries palette maps to the basic palette found on the counter_strip.bmp. Thats ordinarily how you can vary the colour of the counters... e.g. on the counter_strip.bmp, what you see as the pink part of the counter is made up of colour (just for example, I dont know the exact number right off) #59. Therefore whatever colour you make colour #59 on the country specific palette (afg.bmp for example) will be what you actually see in the game.

Clear as mud? ok! :D

So how they make the flags is the modify the counter_strip.bmp. They make a block of pixels 6x6 or however big the flags are and make each pixel a different colour # in the palette.

Now to make the flag for the specific country you want, you open up that country's palette and change the colours of each of the colour #s that make up the flag.

For example, lets say the flag portion of the counter_strip.bmp looked something like this (block of pixels, the numbers correspong to what colour # from the palette is assigned to that pixel):

21 22 23 24 25 26
27 28 29 30 31 32
33 34 35 36 37 38
39 40 41 42 43 44
45 46 47 48 49 50
51 52 53 54 55 56

Now in the counter_strip.bmp, #21-56 in the palette might all be magenta, in which case you would just see a block of magenta, indistinguishable from the rest of the counter.

But if, in say, fra.bmp, colours 21,22,27,28,33,34,39,40,45,46,51,52 were blue, 23,24,29,30,35,36,41,42,47,48,53,54 were white, and 25,26,31,32,37,38,43,44,49,50,55,56 were red, well then you'd see the flag of France on that 6x6 block of pixels on the counter.

How's that for a primer? ;)
 
Ok I think you got it but just to be clear, the shapes are not in any way in the pallette, just the colours are there.

The shape is the actual pixels in the counter_strip.bmp... e.g. that block of numbers represents a block of pixels on counter_strip.bmp, the numbers themselves represent colours from the pallette....

It took me awhile to get my head around the whole picture/pallette interaction as well. If you search the forums there are a couple of threads that manage to explain things in some detail.
 
I used to have one, which I used to make the TGW counters and the South American flags for McNaughton. But I lost it, and haven't gotten around to recreating it.

What it did was take a raw RGB data file and convert it to a palette. What it basically does to get that effect is take the 24-bit RGB data and add 8 0 bits to each value, turning it into a sort of RGBA with A as 0. Then it would add the palette header.

Not exactly user-friendly, but it worked. :)
 
It helps some but I really need more specific information, I think I understand the jist of taking the data of a flag I make and pasting it in the space in the picture's palette using a hexadecimal editor but I don't think the palette's order is in the same order when its in hexadecimal code.

If possible, could you give me a walkthrough of how you made a flag alteration on the counter.
 
GC1CEO said:
It helps some but I really need more specific information, I think I understand the jist of taking the data of a flag I make and pasting it in the space in the picture's palette using a hexadecimal editor but I don't think the palette's order is in the same order when its in hexadecimal code.

If possible, could you give me a walkthrough of how you made a flag alteration on the counter.

OK, I'l try.

You need a graphics editing program with some palette handling, and able to save raw rgb. Like Paint Shop Pro. You also need that little program, and the hex editor. And you need to track your files, because you have to know where they are and transfer them from one place to the other when needed. And you might want to create a backup copy of the counter_tag.bmp you're working on.

1 - Pick an image to use for the flag. Say, the "forbidden flag". Open it the graphics editor (or create it in the editor, doesn't matter). Resize it to have a width of 14 and a height of 9. Tidy it up if necessary. Save that new 14x9 image in RAW format. Remember to give it some extension like .raw, because I'm a lazy bugger and didn't make the program parse the input filename. Say you name it evil.raw.

2 - Run the rgb2pal program on that new image. Run rgb2pal evil.raw in the command prompt (I'm assuming you know your way around DOS). This will create a new file, evil.pal.

3 - Take one of the counter_TAG.bmp files. (For simplicity's sake, pick one that already has the colour scheme you want, so you only need to change the flag. ;) With the "forbidden flag", I'm guessing you'll want counter_ger.bmp for the feldgrau.) Open the file in the graphics editor, and save the palette in Microsoft format. (as, say, counter_evil.pal)

4 - With the hex editor, open your counter_evil.pal, and evil.pal (imaginative, ain't I?). You'll need to copy the contents of evil.pal and paste them at offset 0x0020 of counter_evil.pal. You should leave this:
Code:
52 49 46 46   14 04 00 00   50 41 4C 20   64 61 74 61
08 04 00 00   00 03 00 01   00 FF FF 00   FF FF 00 00
before it. Save your palette.

5 - Open counter_ger.bmp in the graphics editor. Load the palette you've edited, maintaining indexes. Save it.

You should now have a counter with a changed flag.
 
Windows xp.

What kind of error do you get?

Did you pass the name of the input file as a parameter to the program? It will crash if you don't. I think it shouldn't, but it does.

Oh, hell, here's the source code (C, btw :)):

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void parse(FILE *in_f, FILE *out_f){
	void * buffer, * padding;
	int i, j, size;

	padding = calloc(2,1);
	buffer = calloc(3,1);
	while(fread(buffer, 3, 1, in_f)){
		fwrite(buffer, 3, 1, out_f);
		fwrite(padding, 1, 1, out_f);
	}
}

int main(int argc,char *argv[])
{
	FILE * in_f;
	FILE * out_f;
	char * o_f_name;

	if (argc) {
		o_f_name = malloc(strlen(argv[1]));
		strlcpy(o_f_name, argv[1], (strlen(argv[1]) - 3));
		strcat(o_f_name, ".pal");
		out_f = fopen(o_f_name, "wb");
		in_f = fopen(argv[1], "rb");
		parse(in_f, out_f);
		fclose(out_f);
	}
	else {
		printf ("Error\n");
	}
	return 0;
}
 
A few notes:

I could only get this working with Adobe Photoshop, apparently there is no universal RAW file standard and it only seems to work with the RAW file format used with Adobe Photoshop.

A proper converted flag palette will go out to the 7th position in offset 01F0, other RAW file formats only go out to about half of that.

So far I have done ones for Germany (yes the forbidden flag which btw was not easy at such a small resolution) and for Japan, I love the rising sun flag for Japan although technically it was never the official japanese flag, merely was their naval war ensign and a modified version is the ensign for their self-defense forces.

At any rate, going to redo some of the flags/counters (including adding counter flags for the countries using the generic minors one).

BTW can somebody sticky this, since it gives a tutorial of how to change the flag on the counter ?