Compositor: prefill only uncovered rows when backdrop not fully covered (Unit 4)
This commit is contained in:
@@ -92,8 +92,53 @@ public sealed class SceneCompositor
|
|||||||
var covered = liveCaptureFrame != null
|
var covered = liveCaptureFrame != null
|
||||||
&& liveCaptureFrame.Width == cropW && liveCaptureFrame.Height == cropH;
|
&& liveCaptureFrame.Width == cropW && liveCaptureFrame.Height == cropH;
|
||||||
if (!covered)
|
if (!covered)
|
||||||
|
{
|
||||||
|
if (liveCaptureFrame != null)
|
||||||
|
{
|
||||||
|
var (uScale, uOx, uOy) = StretchMath.UniformToFill(cropW, cropH, liveCaptureFrame.Width, liveCaptureFrame.Height);
|
||||||
|
var drawnW = liveCaptureFrame.Width * uScale;
|
||||||
|
var drawnH = liveCaptureFrame.Height * uScale;
|
||||||
|
var ox = (int)Math.Floor(uOx);
|
||||||
|
var oy = (int)Math.Floor(uOy);
|
||||||
|
var oh = (int)Math.Ceiling(oy + drawnH);
|
||||||
|
var ow = cropW;
|
||||||
|
if (oy > 0)
|
||||||
|
{
|
||||||
|
var topCount = oy * ow;
|
||||||
|
for (var i = 3; i < topCount * 4; i += 4)
|
||||||
|
buffer[i] = 255;
|
||||||
|
}
|
||||||
|
if (oh < cropH)
|
||||||
|
{
|
||||||
|
var start = oh * ow;
|
||||||
|
var bottomCount = (cropH - oh) * ow;
|
||||||
|
for (var i = start * 4 + 3; i < (start + bottomCount) * 4; i += 4)
|
||||||
|
buffer[i] = 255;
|
||||||
|
}
|
||||||
|
if (ox > 0 || (int)Math.Ceiling(uOx + drawnW) < cropW)
|
||||||
|
{
|
||||||
|
var x0s = (int)Math.Floor(uOx);
|
||||||
|
var x1s = (int)Math.Ceiling(uOx + drawnW);
|
||||||
|
for (var y = oy; y < oh && y < cropH; y++)
|
||||||
|
{
|
||||||
|
var di = (y * ow + 0) * 4;
|
||||||
|
for (var x = 0; x < x0s && x < ow; x++)
|
||||||
|
{
|
||||||
|
buffer[di + x * 4 + 3] = 255;
|
||||||
|
}
|
||||||
|
for (var x = x1s; x < ow; x++)
|
||||||
|
{
|
||||||
|
buffer[di + x * 4 + 3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (var i = 3; i < buffer.Length; i += 4)
|
for (var i = 3; i < buffer.Length; i += 4)
|
||||||
buffer[i] = 255; // opaque black base
|
buffer[i] = 255; // opaque black base
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (liveCaptureFrame != null)
|
if (liveCaptureFrame != null)
|
||||||
BlitContent(buffer, cropW, cropH, 0, 0, cropW, cropH, liveCaptureFrame, 1f, false, false);
|
BlitContent(buffer, cropW, cropH, 0, 0, cropW, cropH, liveCaptureFrame, 1f, false, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user