11

I want to find a way to convert RGB colors used by classic Mac OS to RGB colors that are understandable to modern image editors and to web browsers.

The two palettes that are subjects of my interest are as follows:

System 4.1 system colors

R      G      B
65535, 65535, 65535
64512, 62333,  1327
65535, 25738,   652
56683,  2242,  1698
62167,  2134, 34028
18147,     0, 42302
    0,     0, 54272
  577, 43860, 60159
 7969, 46995,  5169
    0, 25775,  4528
22016, 11421,  1316
37079, 29024, 14900
49152, 49152, 49152
32768, 32768, 32768
16384, 16384, 16384
    0,     0,     0

System 7 icon colors

R      G      B
65535, 65535, 52428
65535, 52428, 39321
52428, 39321, 26214
65535, 26214, 13107
13107, 65535, 39321
    0, 48059,     0
13107, 39321, 26214
13107, 26214, 26214
39321, 65535, 65535
    0, 39321, 65535
    0,     0, 56797
13107,     0, 39321
52428, 52428, 65535
39321, 39321, 65535
26214, 26214, 52428
13107, 13107, 26214
65535, 26214, 52428
39321,     0, 26214
39321, 26214, 39321
65535, 65535, 65535
61166, 61166, 61166
56797, 56797, 56797
52428, 52428, 52428
48059, 48059, 48059
43690, 43690, 43690
34952, 34952, 34952
30583, 30583, 30583
21845, 21845, 21845
17476, 17476, 17476
 8738,  8738,  8738
 4369,  4369,  4369
    0,     0,     0
65535, 65535,     0
56797,     0,     0

As you can see, the color values are from 0 to 65535. What I don't understand is that how to properly, that is, precisely, convert them to "modern" RGB, such as, for example, rgb(100, 149, 237) for cornflower blue.

I have asked on Stack Overflow and there is an answer there, but:

  1. As follows from the discussion there, RGB565 is not the same as RGB16, but both of them use color values from 0 to 65535, and this means I don't understand which of these two RGB variants were used by classic Mac OS, and this means I don't know whether the answer there gives accurate values if we talk about converting colors of classic Mac OS.

  2. Later I have found another answer on Stack Overflow, and after reading it I suspect that the conversion proposed in the first answer is not really correct at all, because shifting for G must be different from shifting for R and B.

If there are vintage Mac gurus here, plese help me to not go cranky.

12
  • That is a difficult one. First of all, as there are three values, each 0-65535 for 16 bits, it can't be RGB565. It could very well be RGB16 if that is what you mean by each component, R, G and B, having a 16-bit value. So it is possible that just divide by 256 and use the result as 8-bit RGB numbers. However one element is still missing; the definition of colour space used for the numbers. For example, having a 100% red does not tell you which exact shade of red light it is as there are different standards so the same shade of red will use a different color values in another standard.
    – Justme
    Jul 31 at 12:44
  • RGB565 uses 16 bit overall, not per component. So it's using 5 bits for red, 6 bits for green, and 5 bits for blue, packed into a single 16 bit value. I don't know anything about classic MacOS, but if it would really use 48 bit colors (16 bit per component), then you would simply calculate (componentValue / 256) for each color component to get down to RGB888.
    – DarkDust
    Jul 31 at 12:45
  • 2
    @yrslv2022 No, best thing is to figure out what the numbers mean, i.e. what is the colour space of those numbers. If they are in sRGB standard but 16-bit, then divide by 256 and you have numbers that are 8-bit and still in sRGB standard. If you don't know which colour space standard the 16-bit source numbers use and you don't know in which colour space standard you need the 8-bit result numbers, the colours will not look correct by simply dividing them by 256 (which is same as bit shifting by 8).
    – Justme
    Jul 31 at 13:25
  • 5
    Apple used a different gamma on their CRT monitors than PCs or workstations. I remember switching between all three systems and seeing JPEG images look slightly different. Its not just the RGB values from the system pallet you want to recreate but also the monitor gamma. Jul 31 at 15:28
  • 1
    Shift by 8 (>> 8) means divide by 256. Dividing by 256 is the same as shifting by 8. It's kind of like Germany is the same as Deutschland - two ways of saying exactly the same thing. However, dividing by 257 is not the same thing a shifting by 8
    – slebetman
    Aug 2 at 8:41

3 Answers 3

14

The fact that the color channel values range from 0 to 65535 instead of 0 to 255 is a trivial difference. You can just divide by 65535/255 = 257 (and round to the nearest integer).

The real problem is that RGB on old color Macs is not the same as sRGB, the RGB standard used on the web and in most digital images. The Macs used a gamma of 1.8, while sRGB is closer to 2.2 (not really, but it's a reasonable approximation). They apparently used a 6500K white point, which fortunately matches the typical sRGB white point. I don't know what RGB primaries they used; it's maddeningly difficult to find information about such things.

If you ignore the problem with the primaries and just hope they're the same (dubious), then you can convert each number as follows:

sRGB value = 255 CsRGB( (Mac value / 65535)1.8 )

where CsRGB is the function shown here.

8
  • 5
    With regards to the primaries, recall that sRGB was a formal characterization of common CRT monitors and office viewing conditions at the time. sRGB's primaries match Rec. 709, which matches Rec. 601, because that's how CRTs were made back then. Unlike today, there was little variation in display technology. A lot was largely unspecified for the first 40 years of color TV; only at the cusp of plasma and LCD did questions arise. Even later, BT.1886 only came in 2011 to specify the EOTF, when engineers realized they wouldn't have much longer to characterize pure-analog CRT displays.
    – user71659
    Jul 31 at 21:05
  • Thanks a lot, benrg. I'm surprised to see such a scientific answer.
    – yrslv2022
    Jul 31 at 23:32
  • Could you additionally explain how to use this formula? For example, here is the second color from the first table: 64512, 62333, 1327. So I need to divide 64512 by 65535, raise it to the power of 1.8, and then multiply by 255, and that's it? 64512 --> 247.879804311640353, is this correct? I mean, what confuses me is that you say "...where Csrgb is the function shown here." Do I need to use the function from the Wikipedia somehow?
    – yrslv2022
    Aug 1 at 1:09
  • 1
    @yrslv2022 You need to use the function from Wikipedia. If that's too complicated, a reasonably good approximation is sRGB value = 255 * (Mac value / 65535)**(1.8/2.2) where ** means exponentiation.
    – benrg
    Aug 1 at 1:42
  • @user71659 No, BT.601 does not match BT.709, because if they did match, there would be no need for both. The sRGB does base on BT.709.
    – Justme
    Aug 1 at 12:06
11

For the System 7 icon colours at least, it may help to look at them as hex values:

R      G      B
65535, 65535, 52428      :  ffff, ffff, cccc
65535, 52428, 39321      :  ffff, cccc, 9999
52428, 39321, 26214      :  cccc, 9999, 6666
65535, 26214, 13107      :  ffff, 6666, 3333
13107, 65535, 39321      :  3333, ffff, 9999
    0, 48059,     0      :  0000, bbbb, 0000
13107, 39321, 26214      :  3333, 9999, 6666
13107, 26214, 26214      :  3333, 6666, 6666
39321, 65535, 65535      :  9999, ffff, ffff
    0, 39321, 65535      :  0000, 9999, ffff
    0,     0, 56797      :  0000, 0000, dddd
13107,     0, 39321      :  3333, 0000, 9999
52428, 52428, 65535      :  cccc, cccc, ffff
39321, 39321, 65535      :  9999, 9999, ffff
26214, 26214, 52428      :  6666, 6666, cccc
13107, 13107, 26214      :  3333, 3333, 6666
65535, 26214, 52428      :  ffff, 6666, cccc
39321,     0, 26214      :  9999, 0000, 6666
39321, 26214, 39321      :  9999, 6666, 9999
65535, 65535, 65535      :  ffff, ffff, ffff
61166, 61166, 61166      :  eeee, eeee, eeee
56797, 56797, 56797      :  dddd, dddd, dddd
52428, 52428, 52428      :  cccc, cccc, cccc
48059, 48059, 48059      :  bbbb, bbbb, bbbb
43690, 43690, 43690      :  aaaa, aaaa, aaaa
34952, 34952, 34952      :  8888, 8888, 8888
30583, 30583, 30583      :  7777, 7777, 7777
21845, 21845, 21845      :  5555, 5555, 5555
17476, 17476, 17476      :  4444, 4444, 4444
 8738,  8738,  8738      :  2222, 2222, 2222
 4369,  4369,  4369      :  1111, 1111, 1111
    0,     0,     0      :  0000, 0000, 0000
65535, 65535,     0      :  ffff, ffff, 0000
56797,     0,     0      :  dddd, 0000, 0000

You'll see that these only contain 16 unique values, all with four identical hex digits. It would suggest that only 4 bits per component were significant. Thus a single digit #RGB would suffice.

Rather than baking in old Mac colourspaces, it might be worth embedding an ICC colour profile in any images you generate to let modern systems do the mapping for you. Colour management has got a lot more involved that the simple gamma correction we used to do three decades ago.

4
  • Thanks a lot, scruss. "Thus a single digit #RGB would suffice." - Could you elaborate what you mean by this?
    – yrslv2022
    Jul 31 at 23:29
  • 4
    Using the first colour (65535, 65535, 52428 : ffff, ffff, cccc) as an example. It represents each channel using two bytes, or 48 bits per pixel (#ffffffffcccc). You can encode the same colour without loss at 12 bits per pixel as #ffcor at 24 bits per pixel as #ffffcc. This is before colour space conversion
    – scruss
    Aug 1 at 1:26
  • @yrslv2022 this is far too simplistic to be useful. The gamma difference alone will make it wildly inaccurate. Aug 2 at 2:25
  • @MarkRansom - as a full answer, maybe. But realizing that Apple's use of 16-bit per component was way beyond hardware capabilities of the day is important. I never said that these RGB values were modern output sRGB values, either: Apple's use of γ = 1.8 made images come out wildly different from PC images, and these quantized values are in Apple's colour space
    – scruss
    Aug 2 at 14:02
9

If you have images that use these palettes, the AppleRGB.icc colour profile can be used to apply the γ = 1.8 of the old Apple Trinitron colour monitors, amongst other corrections required for colour management.

Taking your colour lists:

  • converted them to NetPBM's Plain PPM text format with one pixel per colour;
  • used NetPBM's pamtotiff -truecolor to convert them to TIFF;
  • used Little Color Management System's tificc to apply the AppleRGB colour profile and create an sRGB TIFF file;
  • used NetPBM's tifftopnm -byrow and pnmnoraw commands to make a plain PPM file of the converted data.

With some messing about with awk and paste I made the following tables:

System 4.1 system colours

 65535, 65535, 65535    =>   255, 255, 255
 64512, 62333,  1327    =>   251, 244,  48
 65535, 25738,   652    =>   255, 124,  22
 56683,  2242,  1698    =>   234,  40,  10
 62167,  2134, 34028    =>   252,  47, 149
 18147,     0, 42302    =>    93,  25, 177
     0,     0, 54272    =>    20,  27, 216
   577, 43860, 60159    =>     0, 184, 237
  7969, 46995,  5169    =>     0, 192,  45
     0, 25775,  4528    =>     0, 117,  31
 22016, 11421,  1316    =>   107,  60,   9
 37079, 29024, 14900    =>   163, 132,  77
 49152, 49152, 49152    =>   203, 203, 203
 32768, 32768, 32768    =>   146, 146, 146
 16384, 16384, 16384    =>    81,  81,  81
     0,     0,     0    =>     0,   0,   0

Input colours:

system 4.1 colour swatch

Converted colours:

system 4.1 colour swatch, corrected

System 7 Icon Colours

 65535, 65535, 52428    =>   255, 254, 215
 65535, 52428, 39321    =>   255, 214, 171
 52428, 39321, 26214    =>   216, 170, 123
 65535, 26214, 13107    =>   255, 126,  70
 13107, 65535, 39321    =>     0, 251, 173
     0, 48059,     0    =>     0, 196,  35
 13107, 39321, 26214    =>    48, 167, 123
 13107, 26214, 26214    =>    60, 120, 121
 39321, 65535, 65535    =>   161, 253, 255
     0, 39321, 65535    =>     0, 169, 253
     0,     0, 56797    =>    21,  29, 224
 13107,     0, 39321    =>    71,  21, 167
 52428, 52428, 65535    =>   214, 214, 254
 39321, 39321, 65535    =>   170, 171, 253
 26214, 26214, 52428    =>   123, 123, 211
 13107, 13107, 26214    =>    67,  68, 120
 65535, 26214, 52428    =>   255, 129, 212
 39321,     0, 26214    =>   175,  30, 120
 39321, 26214, 39321    =>   172, 124, 168
 65535, 65535, 65535    =>   255, 255, 255
 61166, 61166, 61166    =>   241, 241, 241
 56797, 56797, 56797    =>   228, 228, 228
 52428, 52428, 52428    =>   214, 214, 214
 48059, 48059, 48059    =>   199, 199, 199
 43690, 43690, 43690    =>   184, 184, 184
 34952, 34952, 34952    =>   154, 154, 154
 30583, 30583, 30583    =>   138, 138, 138
 21845, 21845, 21845    =>   104, 104, 104
 17476, 17476, 17476    =>    86,  86,  86
  8738,  8738,  8738    =>    45,  45,  45
  4369,  4369,  4369    =>    21,  21,  21
     0,     0,     0    =>     0,   0,   0
 65535, 65535,     0    =>   254, 253,  50
 56797,     0,     0    =>   234,  37,   4

Input colours:

system 7 icon colours

Converted colours:

system 7 icon colours, corrected

You'll notice that these colour transforms don't directly map individual input R, G or B channels to one corresponding output channel value. This is to be expected when using a perceptual colour mapping.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .