Skip to content

Commit

Permalink
tweak scale down expression
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Jan 3, 2025
1 parent 5fb2005 commit f797d3d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ constexpr channel_t scale_up(channel_t value, unsigned shift) {

// scale down value, rounding evenly
constexpr channel_t scale_down(channel_t value, unsigned shift) {
return (value + (1 << (shift - 1))) >> shift;
return (value * ((1 << shift) - 1)) / 255;
}

//
Expand Down

0 comments on commit f797d3d

Please sign in to comment.