常见混合结果展示
图层混合后变暗
正常模式(normal)
混合色*不透明度+(100%-混合色不透明度)
void layerblend_normal(Mat &base,Mat &blend,Mat &dst,float opacity)
{
if (base.rows != blend.rows ||
base.cols != blend.cols ||
base.type() != blend.type())
return;
dst = Mat::zeros(base.rows,base.cols,base.type());
for (int h = 0;h < base.rows;h ++)
{
uchar *d1 = base.ptr<uchar>(h);
uchar *d2 = blend.ptr<uchar>(h);
uchar *d3 = dst.ptr<uchar>(h);
for (int w = 0;w < base.cols;w ++)
{
int cw = w * base.channels();
for (int c = 0;c < base.channels();c ++)