News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Transparent player colors

Started by iv5343, November 15, 2023, 04:23:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

iv5343

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

Player colors and transparency

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.

ceeac

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, function recode_img_src_target(
Should be fixed in r11003.

Thanks for the reports!