MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / RGBToGreyscale

Function RGBToGreyscale

src/heightmap.cpp:69–74  ·  view source on GitHub ↗

* Convert RGB colours to Greyscale using 29.9% Red, 58.7% Green, 11.4% Blue * (average luminosity formula, NTSC Colour Space) */

Source from the content-addressed store, hash-verified

67 * (average luminosity formula, NTSC Colour Space)
68 */
69static inline uint8_t RGBToGreyscale(uint8_t red, uint8_t green, uint8_t blue)
70{
71 /* To avoid doubles and stuff, multiply it with a total of 65536 (16bits), then
72 * divide by it to normalize the value to a byte again. */
73 return ((red * 19595) + (green * 38470) + (blue * 7471)) / 65536;
74}
75
76
77#ifdef WITH_PNG

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected