Skip to content

Commit c4bb9cb

Browse files
committed
small improvements on the PorterDuff functions
line 167: dstW + srcW + blendW = dstW + (src.W - blendW) + blendW = destination.W + source.W - blendW + blendW = destination.W + source.W line 194: dstW + blendW = (destination.W - blendW) + blendW = destination.W - blendW + blendW = destination.W
1 parent c59a32e commit c4bb9cb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public static Vector4 Over(Vector4 destination, Vector4 source, Vector4 blend)
164164
float srcW = source.W - blendW;
165165

166166
// calculate final alpha
167-
float alpha = dstW + srcW + blendW;
167+
float alpha = dstW + source.W;
168168

169169
// calculate final color
170170
Vector4 color = (destination * dstW) + (source * srcW) + (blend * blendW);
@@ -191,7 +191,7 @@ public static Vector4 Atop(Vector4 destination, Vector4 source, Vector4 blend)
191191
float dstW = destination.W - blendW;
192192

193193
// calculate final alpha
194-
float alpha = dstW + blendW;
194+
float alpha = destination.W;
195195

196196
// calculate final color
197197
Vector4 color = (destination * dstW) + (blend * blendW);

0 commit comments

Comments
 (0)