Browse Source

brightness should take into account tranparency as well

rexim 3 years ago
parent
commit
30c1a2e8b0
1 changed files with 2 additions and 1 deletions
  1. 2 1
      examples/vc.c

+ 2 - 1
examples/vc.c

@@ -96,10 +96,11 @@ char color_to_char(uint32_t pixel)
     size_t r = OLIVEC_RED(pixel);
     size_t g = OLIVEC_GREEN(pixel);
     size_t b = OLIVEC_BLUE(pixel);
-    // TODO: brightness should take into account tranparency as well
+    size_t a = OLIVEC_ALPHA(pixel);
     size_t bright = r;
     if (bright < g) bright = g;
     if (bright < b) bright = b;
+    bright = bright*a/255;
 
     char table[] = " .:a@#";
     size_t n = sizeof(table) - 1;