hi,

i've the following problem/question:

i've created a simple "map" for a little game i'm coding. the map has two colors, one ground color and one water color. i want to save the color values in an *.ini file to read them out in my program. my game then uses "GetPixel" to find out the color of a pixel on the map. then it should compare the values of the API and the value that is stored in the INI file.

but GetPixel returns a RGB value, and i don't understand clearly what that is. when creating the map, i can see the colors in two different styles: R:128 G:64 B:0 and #804000
which style, and how shall i store them in the INI file? the problem is, that i gotta convert that string values in "real" numbers finally. so how to save them, so that i can compare the value in the ini file with the value that is returned from GetPixel?

thanks..
NOP
Posted on 2002-05-30 07:43:36 by NOP-erator
RGB values are 24-bit color value stored as three 8-bit numbers
each is 0 to 255 (00 to FFh)
and they are often stored in a dword with one byte being unused.

ARGB (or RGBA) uses the extra byte for Alpha value.
Posted on 2002-05-30 07:48:02 by Homer
hi

thanks for the fast answer, but:

which value shall i store in the ini file now? i mean, i couldn't find any function to convert the hex string into hexnumber. and how to save the decimal values in "one number" if this should be the solution?

thanks
Posted on 2002-05-30 07:52:09 by NOP-erator
NOP-erator, the easiest way is to just store one DWORD, but the design in up to you. ;) There are a few hundred ways to accomplish the task. You could store each RGB value as a separate number, you could store in hex or decimal. The choices are yours - you are the programmer. All the conversion functions you need are in MASM32. If my reply sounds lame, please give us more info - I don't understand what your asking for. Search the board for "Color RGB" and you should turn up some macros and code.
Posted on 2002-05-30 08:24:20 by bitRAKE
From the information you've given us, the information seems to be a set of booleans.
You could store it just as plain text "011100"...
Or store the hex string of your map...
Personally I think an INI isn't suited to this, and a straight binary file would do better. But the choice really is yours.

There are plenty of ways to do this, and the code needed depends entirely on what you want to do, and indeed possibly on the features you want to implement.
If for example you want to be able to change the colour of the map, then you have to regenerate the whole thing, but if you instead offer a choice to the user of sky colour, and ground colour, then a level of indirection (i.e. a palette) would serve you better.

Mirno
Posted on 2002-05-30 08:58:05 by Mirno
If you intend your .ini file to be hand edited then maybe have something like
COLOR=Green
COLOR=LightGreen
etc...
You could define as many colors as you want. Your program could contain a table of rgb color values stored as dwords each with a coresponding color name string
Posted on 2002-05-30 22:49:38 by Kudos