File diff r21363:d44cc377eeb3 → r21364:fc9d03d2e2b8
src/blitter/32bpp_base.hpp
Show inline comments
 
@@ -92,48 +92,61 @@ public:
 
			colour.a = 255;
 
			return colour;
 
		}
 

	
 
		return ComposeColourPANoCheck(colour, a, current);
 
	}
 

	
 
	/**
 
	 * Make a pixel looks like it is transparent.
 
	 * @param colour the colour already on the screen.
 
	 * @param nom the amount of transparency, nominator, makes colour lighter.
 
	 * @param denom denominator, makes colour darker.
 
	 * @return the new colour for the screen.
 
	 */
 
	static inline Colour MakeTransparent(Colour colour, uint nom, uint denom = 256)
 
	{
 
		uint r = colour.r;
 
		uint g = colour.g;
 
		uint b = colour.b;
 

	
 
		return Colour(r * nom / denom, g * nom / denom, b * nom / denom);
 
	}
 

	
 
	/**
 
	 * Make a colour dark grey, for specialized 32bpp remapping.
 
	 * @param r red component
 
	 * @param g green component
 
	 * @param b blue component
 
	 * @return the brightness value of the new colour, now dark grey.
 
	 */
 
	static inline uint8 MakeDark(uint8 r, uint8 g, uint8 b)
 
	{
 
		/* Magic-numbers are ~66% of those used in MakeGrey() */
 
		return ((r * 13063) + (g * 25647) + (b * 4981)) / 65536;
 
	}
 

	
 
	/**
 
	 * Make a colour grey - based.
 
	 * @param colour the colour to make grey.
 
	 * @return the new colour, now grey.
 
	 */
 
	static inline Colour MakeGrey(Colour colour)
 
	{
 
		uint r = colour.r;
 
		uint g = colour.g;
 
		uint b = colour.b;
 

	
 
		/* To avoid doubles and stuff, multiple it with a total of 65536 (16bits), then
 
		 *  divide by it to normalize the value to a byte again. See heightmap.cpp for
 
		 *  information about the formula. */
 
		uint grey = ((r * 19595) + (g * 38470) + (b * 7471)) / 65536;
 

	
 
		return Colour(grey, grey, grey);
 
	}
 

	
 
	static const int DEFAULT_BRIGHTNESS = 128;
 

	
 
	static inline Colour AdjustBrightness(Colour colour, uint8 brightness)
 
	{
 
		/* Shortcut for normal brightness */
 
		if (brightness == DEFAULT_BRIGHTNESS) return colour;