/// <summary> /// Draws the video on to the main layer, using the opacity mask /// </summary> private void RenderVideoAndOpacityMask(DrawingLayer layer) { layer.BeginDraw(); /* Clear the old drawing layer*/ layer.Clear(); /* Scale the video brush to match the size of the layer */ m_videoBrush.Transform = new ScaleTransform { ScaleX = (float)layer.Width / m_player.NaturalSize.Width, ScaleY = (float)layer.Height / m_player.NaturalSize.Height }; /* Draws the contents of the video brush, using the given opacity mask, onto the layer. */ layer.FillOpacityMask(m_videoBrush, m_opacityMask, new RectangleF(0, 0, layer.Width, layer.Height), new RectangleF(0, 0, layer.Width, layer.Height)); layer.EndDraw(); }
protected override void DrawLayer(DrawingLayer outputLayer) { base.DrawLayer(outputLayer); DepthFrame.MinThreshold = (ushort)this.MinThreshold; DepthFrame.MaxThreshold = (ushort)this.MaxThreshold; ushort minValue; ushort maxValue; var img = DepthFrame.ToDirectCanvasImage(Factory, out minValue, out maxValue); effectLayer.CopyFromImage(img); Rect crop = DepthFrame.Crop; Rectangle rect = new Rectangle((int)crop.X, (int)crop.Y, (int)crop.Width, (int)crop.Height); RectangleF rectf = new RectangleF((float)crop.X, (float)crop.Y, (float)crop.Width, (float)crop.Height); colorMapEffect.MinThreshold = (float)MinThreshold; colorMapEffect.MaxThreshold = (float)MaxThreshold; colorMapEffect.MinValue = minValue; colorMapEffect.MaxValue = maxValue; unpackEffect.TexSize = new DirectCanvas.Misc.Size(effectLayer.Width, effectLayer.Height); effectLayer.ApplyEffect(unpackEffect, effectLayer2, true); effectLayer2.ApplyEffect(colorMapEffect, outputLayer, true); outputLayer.BeginDraw(); outputLayer.DrawRectangle(rectBrushBackground, rectf, 3f); outputLayer.DrawRectangle(rectBrushForeground, rectf, 1f); outputLayer.EndDraw(); }