The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: iv5343 on November 15, 2023, 04:23:38 PM

Title: Transparent player colors
Post by: iv5343 on November 15, 2023, 04:23:38 PM
There's a bug in the transparent player color conversion in file simgraph16.cc, function recode_img_src_target(), of Simutrans r11001
and also the released 123.0.1:

#ifdef RGB555
PIXVAL pix = ((rgb >> 6) & 0x0380) | ((rgb >>  4) & 0x0038) | ((rgb >> 2) & 0x07);
#else
PIXVAL pix = ((rgb >> 6) & 0x0380) | ((rgb >>  3) & 0x0078) | ((rgb >> 2) & 0x07);
#endif

should be

//         msb          lsb
// rgb555: xrrrrrgggggbbbbb
// rgb565: rrrrrggggggbbbbb
// translucent:  rrrggggbbb
#ifdef RGB555
PIXVAL pix = ((rgb >> (15 - 10)) & 0x0380) |
             ((rgb >> (10 - 7)) & 0x0078) |
             ((rgb >> (5 - 3)) & 0x0007);
#else
PIXVAL pix = ((rgb >> (16 - 10)) & 0x0380) |
             ((rgb >> (11 - 7)) & 0x0078) |
             ((rgb >> (5 - 3)) & 0x0007);
#endif

A brief search brought up two bug reports which may be related, one has a test file attached (I used my own, a vehicle so the background changes).  It may be a good idea to keep such files in the source tree.

Green discoloration in transparent player color (https://forum.simutrans.com/index.php?topic=17641.0)

Player colors and transparency (https://forum.simutrans.com/index.php?topic=20345.0)

An unrelated minor issue, the display_snapshot() function converts PIXVALs to RGB 8:8:8. It should scale the color components or e.g. white turns into light grey. I can provide a patch if you wish.
Title: Re: Transparent player colors
Post by: ceeac on November 16, 2023, 06:59:35 PM
Quote from: iv5343 on November 15, 2023, 04:23:38 PMAn unrelated minor issue, the display_snapshot() function converts PIXVALs to RGB 8:8:8. It should scale the color components or e.g. white turns into light grey. I can provide a patch if you wish.
Should be fixed in r11002.

Quote from: iv5343 on November 15, 2023, 04:23:38 PMThere's a bug in the transparent player color conversion in file simgraph16.cc (https://simgraph16.cc/), function recode_img_src_target(
Should be fixed in r11003.

Thanks for the reports!