+/*
+ Calculate the color of a single pixel drawn on top of another pixel.
+
+ This is a little more complicated than just video::SColor::getInterpolated
+ because getInterpolated does not handle alpha correctly. For example, a
+ pixel with alpha=64 drawn atop a pixel with alpha=128 should yield a
+ pixel with alpha=160, while getInterpolated would yield alpha=96.
+*/
+static inline video::SColor blitPixel(const video::SColor &src_c, const video::SColor &dst_c, u32 ratio)
+{
+ if (dst_c.getAlpha() == 0)
+ return src_c;
+ video::SColor out_c = src_c.getInterpolated(dst_c, (float)ratio / 255.0f);
+ out_c.setAlpha(dst_c.getAlpha() + (255 - dst_c.getAlpha()) *
+ src_c.getAlpha() * ratio / (255 * 255));
+ return out_c;
+}
+