LDraw.org Discussion Forums
Translate old colour codes - Printable Version

+- LDraw.org Discussion Forums (https://forums.ldraw.org)
+-- Forum: Models and Parts (https://forums.ldraw.org/forum-18.html)
+--- Forum: Parts Authoring (https://forums.ldraw.org/forum-19.html)
+--- Thread: Translate old colour codes (/thread-15259.html)



Translate old colour codes - Magnus Forsberg - 2015-01-22

Many old parts use a blended colour code. A mix of two ldraw base colours.
New parts can have a RGB-based colour code
Both are ways to create a colour not present in ldconfig.ldr

Is there a way to 'translate' the old code to a new code?


Re: Translate old colour codes - Roland Melkert - 2015-01-22

Yes, you only need to calculate the RGB of the dithered color code by applying the known base colors from the LDConfig, like so (c++ pseudo)

Code:
A=(code-256) >> 4
B=(code-256) & 0x0F

r=(A.r+B.r)/2.0
g=(A.g+B.g)/2.0
b=(A.b+B.b)/2.0

edit: forgot the -256


Re: Translate old colour codes - Philippe Hurbain - 2015-01-23

Color on printed stuff is so imprecise (pigment mismatch, plastic color bleeding through and so on) that I think the best way is to visually match color with an existing ldconfig color. Don't forget also that initial dithered color was eyeballed too, probably using an uncalibrated monitor to match color...


Re: Translate old colour codes - Magnus Forsberg - 2015-01-23

Thanks Roland, but I don't speak 'code'. I don't even know how to read that math.
Is there a tool that can do that calculation? ColourManager?

I'm reworking many of the torsos from the early Pirates. They all need to become BFC compliant.

All files use the same code 486. Some sort of light brown leather. But all the pictures show different shades of brown, as Philo says.
Reddish brown is to dark. I think I'll go with Medium Dark Flesh

   


Re: Translate old colour codes - Max Martin Richter - 2015-01-23

I understand the code in the following way:
To get the new value for red/green/blue you have to sum the red/green/blue values and divide it by two.

An example:
You want to mix the LDraw-Colours blue (1) and Orange (25)
RGB of blue: 0055BF
RGB of orange: FE8A18

Now take the first to positions: 00 and FE -> sum is FE -> divide by two makes 7F
Now position three and four: 55 and 8A -> sum is DF -> divide by two makes 6F
Now position five and six: BF and 18 -> sum is D7 -> divide by two makes 6B

New colour is 7F6F6B

Please note that the windows calculator can handle hex data in the programmer mode (Win Vista and Win 7).

/Max


Re: Translate old colour codes - Max Martin Richter - 2015-01-23

I just programmed a small tool for this purpose
Comments are welcome (a symbol as well).

/Max


Re: Translate old colour codes - Philippe Hurbain - 2015-01-24

Quote:RGB of blue: 0055BF
RGB of orange: FE8A18
That's current definition of blue and orange per ldconfig, but certainly not the RGB values of EGA/VGA era when this mix was defined... And it would be nice if the tool computed the closest ldconfig color.


Re: Translate old colour codes - Max Martin Richter - 2015-01-24

Yes, this would be an idea... I have to think about this, cause my programming skills are a bit limited. Anyway, I'll give it a try the next days...
Okay, I have a basic idea on how to do this...

/Max


Re: Translate old colour codes - Magnus Forsberg - 2015-01-24

Thanks a lot, it works fine.

Maybe some sort of blended colour wheel?


.png   blended01_64x64.png (Size: 10.16 KB / Downloads: 3)


Re: Translate old colour codes - Max Martin Richter - 2015-01-24

Is there any copyright on this colour wheel?

/Max


Re: Translate old colour codes - Magnus Forsberg - 2015-01-24

No, I don't think there is.
The swirl is made by me, in Paint.Net, on a picture a found by googling 'colour wheel'.


Re: Translate old colour codes - Magnus Forsberg - 2015-06-14

I have to come back to the original question, following the findings in this question.
"Is there a way to 'translate' the old code to a new code?"
I want to fix the parts in Niko's list, but I feel very confused now....

ColourSum makes it easy to blend two known colours and helps in finding the nearest LDraw colour, but I can't use it to revers the dithered colour code into a new RGB-code. Or can I?

The same two base colours will give two different dithered codes.
Take two base colour codes, like 7(Lt Grey) and 13(Pink).
If I feed them into this equation
Code:
nb = n1 * 16 + n2 + 256
I get two different dithered codes, 381 or 471, depending on if I set n1=7 or 13. Both looks to be the same shade of pinkish in LDView.

But I also find pairs of code that show different colours in LDView.
Code:
1 381 0 0 0 1 0 0 0 1 0 0 0 1 rect.dat
1 471 2 0 0 1 0 0 0 1 0 0 0 1 rect.dat

1 349 0 0 2 1 0 0 0 1 0 0 0 1 rect.dat
1 469 2 0 2 1 0 0 0 1 0 0 0 1 rect.dat

1 382 0 0 4 1 0 0 0 1 0 0 0 1 rect.dat
1 487 2 0 4 1 0 0 0 1 0 0 0 1 rect.dat

.png   dithered.png (Size: 23.95 KB / Downloads: 3)

Are all the dithered codes paired in two, and why do I sometimes find they're not.
Is it true that code 381 = 471, and should show the same colour?

Why do the same code look very different in LDCad?

There must be some more mathmatical magic involved here.


Re: Translate old colour codes - Roland Melkert - 2015-06-14

Magnus Forsberg Wrote:Why do the same code look very different in LDCad?
You are right those pairs should look the same they differ in LDCad because of a (very stupid) bug. I forgot to subtract the 256 before splitting the color numbers. I've just fixed it and it will look like so from the next version on.


.png   pairs.png (Size: 13.15 KB / Downloads: 3)

LDView shows two yellow tints though, not sure why that is.