Commit 5526bf89 authored by Jody Goldberg's avatar Jody Goldberg
Browse files

Another stab at contrast colours.

parent de7cede0
1999-09-24 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (ms_excel_palette_get) : Change my guess
at what metric to use when selecting white vs black as a contrasting
colour. Use component discrete, rather than a crude luminosity.
at what the therhold pseudo-luminosity is.
1999-09-23 Michael Meeks <michael@nuclecu.unam.mx>
......
......@@ -867,17 +867,22 @@ ms_excel_palette_get (ExcelPalette *pal, guint idx, StyleColor *contrast)
/* Is the contrast colour closer to black or white based
* on this VERY loose metric.
*/
int const guess =
((contrast->color.red > 0x7fff) ? 1 : -1) +
((contrast->color.green > 0x7fff) ? 1 : -1) +
((contrast->color.blue> 0x7fff) ? 1 : -1);
unsigned const guess =
contrast->color.red +
contrast->color.green +
contrast->color.blue;
#ifndef NO_DEBUG_EXCEL
if (ms_excel_color_debug > 1) {
printf ("Contrast : %d\n", guess);
printf ("Contrast 0x%x 0x%x 0x%x : 0x%x\n",
contrast->color.red,
contrast->color.green,
contrast->color.blue,
guess);
}
#endif
if (guess < 0) {
/* guess the minimum hacked pseudo-luminosity */
if (guess < (0x20000)) {
#ifndef NO_DEBUG_EXCEL
if (ms_excel_color_debug > 1) {
puts("White");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment