- red_channel[loc] = std::min(red_channel[loc] + (red * alpha / 255), 255);
- green_channel[loc] = std::min(green_channel[loc] + (green * alpha / 255), 255);
- blue_channel[loc] = std::min(blue_channel[loc] + (blue * alpha / 255), 255);
+ if(red != 0)
+ {
+ int redsum = red_channel[loc] + (red * alpha >> 8);
+ red_channel[loc] = redsum & ~0xff ? 0xff : redsum;
+ }
+ if(green != 0)
+ {
+ int greensum = green_channel[loc] + (green * alpha >> 8);
+ green_channel[loc] = greensum & ~0xff ? 0xff : greensum;
+ }
+ if(blue != 0)
+ {
+ int bluesum = blue_channel[loc] + (blue * alpha >> 8);
+ blue_channel[loc] = bluesum & ~0xff ? 0xff : bluesum;
+ }