alpha混合如何在数学上逐个像素地工作? [英] How does alpha blending work, mathematically, pixel-by-pixel?

查看:73
本文介绍了alpha混合如何在数学上逐个像素地工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎不像RGB1 * A1 + RGB2 * A2一样简单...如何截取值?加权?等等.

Seems like it's not as simple as RGB1*A1 + RGB2*A2...how are values clipped? Weighted? Etc.

这是一个与上下文相关的问题吗?是否存在产生不同结果的不同算法?还是一种标准的实施方式?

And is this a context-dependent question? Are there different algorithms, that produce different results? Or one standard implementation?

我对特定于OpenGL的答案特别感兴趣,但是来自其他环境的上下文也很有用.

I'm particularly interested in OpenGL-specific answers, but context from other environments is useful too.

推荐答案

我不了解OpenGL,但通常在另一个像素上绘制一个不透明度A的像素,如下所示:

I don't know about OpenGL, but one pixel of opacity A is usually drawn on another pixel like so:

result.r = background.r * (1 - A) + foreground.r * A
result.g = background.g * (1 - A) + foreground.g * A
result.b = background.b * (1 - A) + foreground.b * A

对多个像素重复此操作.

Repeat this operation for multiple pixels.

这篇关于alpha混合如何在数学上逐个像素地工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆