mirror of
https://github.com/jech/galene.git
synced 2024-12-22 07:15:47 +01:00
Improve background blur blending.
We used blur the image then mask, which caused a halo around the foreground. We now mask then blur.
This commit is contained in:
parent
4852f4d379
commit
2c72a27453
1 changed files with 11 additions and 2 deletions
|
@ -1283,12 +1283,21 @@ let filters = {
|
||||||
ctx.canvas.height = src.videoHeight;
|
ctx.canvas.height = src.videoHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the alpha mask, background is opaque
|
||||||
ctx.globalCompositeOperation = 'copy';
|
ctx.globalCompositeOperation = 'copy';
|
||||||
ctx.filter = `blur(${src.videoWidth / 256}px)`;
|
ctx.filter = 'none';
|
||||||
ctx.drawImage(mask, 0, 0);
|
ctx.drawImage(mask, 0, 0);
|
||||||
|
|
||||||
|
// rather than blurring the original image, we first mask
|
||||||
|
// the background then blur, this avoids a halo effect
|
||||||
ctx.globalCompositeOperation = 'source-in';
|
ctx.globalCompositeOperation = 'source-in';
|
||||||
ctx.filter = `blur(${src.videoWidth / 48}px)`;
|
ctx.filter = 'none';
|
||||||
ctx.drawImage(result.bitmap, 0, 0);
|
ctx.drawImage(result.bitmap, 0, 0);
|
||||||
|
ctx.globalCompositeOperation = 'copy';
|
||||||
|
ctx.filter = `blur(${src.videoWidth / 48}px)`;
|
||||||
|
ctx.drawImage(ctx.canvas, 0, 0);
|
||||||
|
|
||||||
|
// now draw the foreground
|
||||||
ctx.globalCompositeOperation = 'destination-atop';
|
ctx.globalCompositeOperation = 'destination-atop';
|
||||||
ctx.filter = 'none';
|
ctx.filter = 'none';
|
||||||
ctx.drawImage(result.bitmap, 0, 0);
|
ctx.drawImage(result.bitmap, 0, 0);
|
||||||
|
|
Loading…
Reference in a new issue