Mercurial > pidgin.yaz
comparison src/gtkconv.c @ 12352:e3fefd3ebc72
[gaim-migrate @ 14656]
fix the automatic color generation, see the comment I inserted and many
thanks to Err.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 05 Dec 2005 16:32:10 +0000 |
parents | af152afe7bac |
children | e38bd4548897 |
comparison
equal
deleted
inserted
replaced
12351:af152afe7bac | 12352:e3fefd3ebc72 |
---|---|
7514 { | 7514 { |
7515 gulong fg_brightness; | 7515 gulong fg_brightness; |
7516 gulong bg_brightness; | 7516 gulong bg_brightness; |
7517 gulong br_diff; | 7517 gulong br_diff; |
7518 gulong col_diff; | 7518 gulong col_diff; |
7519 | 7519 int fred, fgreen, fblue, bred, bgreen, bblue; |
7520 fg_brightness = (foreground.red * 299 + foreground.green * 587 + foreground.blue * 114) / 1000; | 7520 |
7521 bg_brightness = (background.red * 299 + background.green * 587 + background.blue * 114) / 1000; | 7521 /* this algorithm expects colors between 0 and 255 for each of red green and blue. |
7522 * GTK on the other hand has values between 0 and 65535 | |
7523 * Err suggested I >> 8, which grabbed the high bits. | |
7524 */ | |
7525 | |
7526 fred = foreground.red >> 8 ; | |
7527 fgreen = foreground.green >> 8 ; | |
7528 fblue = foreground.blue >> 8 ; | |
7529 | |
7530 | |
7531 bred = background.red >> 8 ; | |
7532 bgreen = background.green >> 8 ; | |
7533 bblue = background.blue >> 8 ; | |
7534 | |
7535 fg_brightness = (fred * 299 + fgreen * 587 + fblue * 114) / 1000; | |
7536 bg_brightness = (bred * 299 + bgreen * 587 + bblue * 114) / 1000; | |
7522 br_diff = abs(fg_brightness - bg_brightness); | 7537 br_diff = abs(fg_brightness - bg_brightness); |
7523 | 7538 |
7524 col_diff = abs(foreground.red - background.red) + abs(foreground.green - background.green) + abs(foreground.blue - background.blue); | 7539 col_diff = abs(fred - bred) + abs(fgreen - bgreen) + abs(fblue - bblue); |
7540 | |
7541 gaim_debug(GAIM_DEBUG_INFO, NULL, "\n\ntest color is %i,%i,%i\nback color is %i,%i,%i\ndifference is %i\ncontrast is %i\n",fred,fgreen,fblue,bred,bgreen,bblue,col_diff,br_diff); | |
7525 | 7542 |
7526 return ((col_diff > MIN_COLOR_CONTRAST) && (br_diff > MIN_BRIGHTNESS_CONTRAST)); | 7543 return ((col_diff > MIN_COLOR_CONTRAST) && (br_diff > MIN_BRIGHTNESS_CONTRAST)); |
7527 } | 7544 } |
7528 | 7545 |
7529 | 7546 |