Browse Source

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
af/merge-core
Peter Amrehn 6 years ago
parent
commit
afc26ae414
  1. 4
      src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs

4
src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs

@ -164,7 +164,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
float srcW = source.W - blendW;
// calculate final alpha
float alpha = dstW + srcW + blendW;
float alpha = dstW + source.W;
// calculate final color
Vector4 color = (destination * dstW) + (source * srcW) + (blend * blendW);
@ -191,7 +191,7 @@ namespace SixLabors.ImageSharp.PixelFormats.PixelBlenders
float dstW = destination.W - blendW;
// calculate final alpha
float alpha = dstW + blendW;
float alpha = destination.W;
// calculate final color
Vector4 color = (destination * dstW) + (blend * blendW);

Loading…
Cancel
Save