HexEdit/Misc.cpp
COLORREF add_contrast(COLORREF col, COLORREF bg_col)
{
	int hue, luminance, saturation;
	get_hls(col, hue, luminance, saturation);

	int bg_hue, bg_luminance, bg_saturation;
	get_hls(bg_col, bg_hue, bg_luminance, bg_saturation);

	if (bg_luminance >= 50 && luminance > bg_luminance - 25)
	{
		// Decrease luminance to increase contrast
		luminance = bg_luminance - 25;
	}
	else if (bg_luminance < 50 && luminance < bg_luminance + 25)
	{
		// Increase luminance to increase contrast
		luminance = bg_luminance + 25;
	}
	assert(luminance <= 100 && luminance >= 0);

	// Make colour the same shade as col but less "bright"
	return get_rgb(hue, luminance, saturation);
}
// Increase contrast (tone up) if necessary.
// If a colour (col) does not have enough contrast with a background
// colour (bg_col) then increase the contrast.  This is similar to
// passing a -ve value  to tone_up (above) but "tones up" conditionally.
// Returns col with adjusted luminance which may be exactly the
// colour of col if therre is already enough contrast.

Increase contrast (tone up) if necessary.
If a colour (col) does not have enough contrast with a background
colour (bg_col) then increase the contrast.  This is similar to
passing a -ve value  to tone_up (above) but "tones up" conditionally.
Returns col with adjusted luminance which may be exactly the
colour of col if therre is already enough contrast.
Increase contrast ( tone up ) if necessary . If a colour ( col ) does not have enough contrast with a background colour ( bg_col ) then increase the contrast . This is similar to passing a - ve value to tone_up ( above ) but " tones up " conditionally . Returns col with adjusted luminance which may be exactly the colour of col if therre is already enough contrast .
COLORREF add_contrast(COLORREF col, COLORREF bg_col)
{
	int hue, luminance, saturation;
	get_hls(col, hue, luminance, saturation);
	int bg_hue, bg_luminance, bg_saturation;
	get_hls(bg_col, bg_hue, bg_luminance, bg_saturation);
	if (bg_luminance >= 50 && luminance > bg_luminance - 25)
	{
		luminance = bg_luminance - 25;
	}
	else if (bg_luminance < 50 && luminance < bg_luminance + 25)
	{
		luminance = bg_luminance + 25;
	}
	assert(luminance <= 100 && luminance >= 0);
	return get_rgb(hue, luminance, saturation);
}
COLORREF add_contrast ( COLORREF col , COLORREF bg_col ) { int hue , luminance , saturation ; get_hls ( col , hue , luminance , saturation ) ; int bg_hue , bg_luminance , bg_saturation ; get_hls ( bg_col , bg_hue , bg_luminance , bg_saturation ) ; if ( bg_luminance >= 50 && luminance > bg_luminance - 25 ) { luminance = bg_luminance - 25 ; } else if ( bg_luminance < 50 && luminance < bg_luminance + 25 ) { luminance = bg_luminance + 25 ; } assert ( luminance <= 100 && luminance >= 0 ) ; return get_rgb ( hue , luminance , saturation ) ; }
Increase contrast (tone up) if necessary.
Increase contrast ( tone up ) if necessary .
// Decrease luminance to increase contrast
 // Increase luminance to increase contrast
 // Make colour the same shade as col but less "bright"
