惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
S
Schneier on Security
P
Palo Alto Networks Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Securelist
T
Threat Research - Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
V
Vulnerabilities – Threatpost
AI
AI
C
CERT Recently Published Vulnerability Notes
C
Cyber Attacks, Cyber Crime and Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
TaoSecurity Blog
TaoSecurity Blog
O
OpenAI News
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
SecWiki News
SecWiki News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cisco Blogs
K
Kaspersky official blog
Spread Privacy
Spread Privacy
S
Security @ Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
IT之家
IT之家
有赞技术团队
有赞技术团队
B
Blog
T
Tailwind CSS Blog
PCI Perspectives
PCI Perspectives
P
Privacy & Cybersecurity Law Blog
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Webroot Blog
Webroot Blog
博客园 - 叶小钗
Cisco Talos Blog
Cisco Talos Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hacker News: Front Page
The Cloudflare Blog
C
Cybersecurity and Infrastructure Security Agency CISA
美团技术团队
V
V2EX
腾讯CDC
S
SegmentFault 最新的问题
Security Archives - TechRepublic
Security Archives - TechRepublic

博客园 - HotSky

Chrome启用CDP(chrome-devtools-protocol)进行远程操控 WPF 让ScrollViewer支持按住鼠标中键拖拽滚动内容 WPF 让ScrollViewer支持鼠标中键滚动缩放内容 Nodejs使用 nodejs中写sql需要用in时的写法 C#城市最短路径 C#Animation Sqlite PDF附录A: 内容流操作码 WPF FPS类 生命模拟 C# Sql帮助类,可扩展 WPF WriteableBitmap通过GDI+绘制帮助类 Bmp读写二值图 WPF支持任意快捷键+鼠标组合的绑定类 WPF阻止窗体被系统缩放,使用显示器DPI WPF DataGrid自动增长序号列 C#访问或修改私有类、函数、变量、属性 WPF一个简单的属性编辑控件
Alpha混合
HotSky · 2024-08-03 · via 博客园 - HotSky

算法:

前景颜色值: R1,G1,B1,A1
背景颜色值: R2,G2,B2,A2
则混合后颜色值:
  R = R1 * A1 + R2 * A2 * (1-A1)
  G = G1 * A1 + G2 * A2 * (1-A1)
  B = B1 * A1 + B2 * A2 * (1-A1)
  A = 1 - (1 - A1) * (1 - A2) ;

C#:

public static int[] ColorAlpha(int frontA, int frontR, int frontG, int frontB, int backA, int backR, int backG, int backB)
{
    float n1 = 1f, n255 = 255f;
    if(frontA >= n255)
        return new int[] { frontA, frontR, frontG, frontB };
    float r = frontR * frontA / n255 + backR * backA / n255 * (n1 - frontA / n255);
    float g = frontG * frontA / n255 + backG * backA / n255 * (n1 - frontA / n255);
    float b = frontB * frontA / n255 + backB * backA / n255 * (n1 - frontA / n255);
    float a = (n1 - (n1 - frontA / n255) * (n1 - backA / n255)) * n255;
    return new int[] { (int)a, (int)r, (int)g, (int)b};
}

javascript:

//1前景色;2背景色
function colorAlpha(a1,r1,g1,b1,a2,r2,g2,b2){
    if(a1 >= 255)
        return { a: a1, r: r1, g: g1, b: b1 };
    let r = r1 * a1 / 255 + r2 * a2 / 255 * (1 - a1 / 255);
    let g = g1 * a1 / 255 + g2 * a2 / 255 * (1 - a1 / 255);
    let b = b1 * a1 / 255 + b2 * a2 / 255 * (1 - a1 / 255);
    let a = 1 - (1 - a1/255)*(1-a2/255);
    return {a:a, r: r, g: g, b: b};
}