TASK 51 slice 5: webcam Background section in the Layers properties — Remove/Blur PillToggles (radio-exclusive) + Strength slider; strength changes never blank the webcam (new variant inherits the same-effect frame + bitmap). TASK 51 built (Unit: bg-effects UI)
This commit is contained in:
@@ -244,11 +244,18 @@ public partial class MainViewModel
|
||||
config.PropertyChanged += OnWebcamConfigEffectChanged;
|
||||
var key = EffectKeyFor(config);
|
||||
var bitmap = _cameraManager.GetPreviewBitmap(_webcam.DeviceId, key);
|
||||
if (bitmap != null || key.Effect != BackgroundEffect.None)
|
||||
config.VideoImageSource = bitmap;
|
||||
// A strength change within the same effect keeps showing the previous variant's
|
||||
// last frame until the new one renders (no blank flicker while dragging the slider);
|
||||
// switching INTO an effect shows nothing first, so Remove never flashes the room.
|
||||
var sameEffect = _shownEffect.TryGetValue(config, out var shown) && shown.Effect == key.Effect;
|
||||
_shownEffect[config] = key;
|
||||
if (bitmap != null) config.VideoImageSource = bitmap;
|
||||
else if (key.Effect != BackgroundEffect.None && !sameEffect) config.VideoImageSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<WebcamSceneConfig, WebcamEffectKey> _shownEffect = new();
|
||||
|
||||
private void OnWebcamConfigEffectChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName is not (nameof(WebcamSceneConfig.BackgroundEffect) or nameof(WebcamSceneConfig.BackgroundStrength)))
|
||||
|
||||
Reference in New Issue
Block a user