Permalink
Browse files

Fix an off-by-one in the pure int alpha_blend

  • Loading branch information...
1 parent 1ea3fc5 commit 1869a375827e9e25ac595ba180533f4d29454cf1 @klange committed Apr 17, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 userspace/lib/graphics.c
@@ -68,9 +68,9 @@ uint32_t rgb(uint8_t r, uint8_t g, uint8_t b) {
uint32_t alpha_blend(uint32_t bottom, uint32_t top, uint32_t mask) {
uint8_t a = _RED(mask);
- uint8_t red = (_RED(bottom) * (255 - a) + _RED(top) * a) / 256;
- uint8_t gre = (_GRE(bottom) * (255 - a) + _GRE(top) * a) / 256;
- uint8_t blu = (_BLU(bottom) * (255 - a) + _BLU(top) * a) / 256;
+ uint8_t red = (_RED(bottom) * (256 - a) + _RED(top) * a) / 256;
+ uint8_t gre = (_GRE(bottom) * (256 - a) + _GRE(top) * a) / 256;
+ uint8_t blu = (_BLU(bottom) * (256 - a) + _BLU(top) * a) / 256;
return rgb(red,gre,blu);
}

0 comments on commit 1869a37

Please sign in to comment.