当前位置: 首页>>代码示例>>C#>>正文


C# DrawingContext.PushOpacityMask方法代码示例

本文整理汇总了C#中System.Windows.Media.DrawingContext.PushOpacityMask方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.PushOpacityMask方法的具体用法?C# DrawingContext.PushOpacityMask怎么用?C# DrawingContext.PushOpacityMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.DrawingContext的用法示例。


在下文中一共展示了DrawingContext.PushOpacityMask方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnRender

		protected override void OnRender(DrawingContext drawingContext) {
			// draw everything except the reflection
			base.OnRender(drawingContext);

			// set opacity
			drawingContext.PushOpacityMask(opacityMask);

			reflection.Visual = Child;
			var group = new TransformGroup();


			if (Child.RenderTransform is TransformGroup) {
				foreach (var child in ((TransformGroup)Child.RenderTransform).Children) {
					group.Children.Add(child);
				}
			}
			else {
				group.Children.Add(Child.RenderTransform);
			}

			scaleTransform.CenterY = (ActualHeight / 1.5) + ((ActualHeight / 1.5) / 4);
			scaleTransform.CenterX = ActualWidth / 2;
			group.Children.Add(scaleTransform);

			reflection.Transform = group;

			// draw the reflection
			drawingContext.DrawRectangle(
					reflection, null,
					new Rect(0, ActualHeight / 1.5, ActualWidth, ActualHeight / 3));

			// cleanup
			drawingContext.Pop();
		}
开发者ID:rjmurillo,项目名称:Autofac-Visualizer,代码行数:34,代码来源:ReflectionControl.cs

示例2: Render

		public void Render(DrawingContext dc, Point location, Brush tint, int tileIndex)
		{
			var dstRect = new Rect(location, new Size(TileWidth, TileHeight));

			dc.PushOpacityMask(new ImageBrush(_tiles[tileIndex]));
			dc.DrawRectangle(tint, null, dstRect);

			dc.Pop();
		}
开发者ID:treytomes,项目名称:wpf-console,代码行数:9,代码来源:TileSet.cs

示例3: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            // draw everything except the reflection
            base.OnRender(drawingContext);

            // set opacity
            drawingContext.PushOpacityMask(_opacityMask);
            drawingContext.PushOpacity(0.4);

            // set reflection parameters based on content size
            _reflection.Visual = Child;

            // draw the reflection
            drawingContext.DrawRectangle(_reflection, null, new Rect(0, ActualHeight + _gap, ActualWidth, ActualHeight));

            // cleanup
            drawingContext.Pop();
            drawingContext.Pop();
        }
开发者ID:hegaojie,项目名称:MovieHouse,代码行数:19,代码来源:ReflectionControl.cs

示例4: ApplyFilter

        protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height)
        {
            var gradientStops = new GradientStopCollection();
            gradientStops.Add(new GradientStop(SWMColor.FromArgb(0, 0, 0, 0), 0));
            gradientStops.Add(new GradientStop(SWMColor.FromArgb(0, 0, 0, 0), 0.5));
            gradientStops.Add(new GradientStop(SWMColor.FromArgb(180, 0, 0, 0), 1.3));
            gradientStops.Add(new GradientStop(SWMColor.FromArgb(230, 0, 0, 0), 1.7));

            var brush = new RadialGradientBrush(gradientStops)
            {
                GradientOrigin = new Point(0.5, 0.5),
                Center = new Point(0.5, 0.45),
                RadiusX = 0.5,
                RadiusY = 0.5
            };

            dc.DrawImage(source.InnerBitmap, new Rect(0, 0, width, height));

            dc.PushOpacityMask(brush);
            dc.DrawRectangle(new SolidColorBrush(SWMColors.Black), null, new Rect(0, 0, width, height));
            dc.Pop();
        }
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:22,代码来源:VignetteFilter.cs

示例5: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            // draw everything except the reflection
            base.OnRender(drawingContext);

            // set opacity
            drawingContext.PushOpacityMask(_opacityMask);
            drawingContext.PushOpacity(0.3);

            // set reflection parameters based on content size
            _reflection.Visual = Child;
            ((ScaleTransform)_reflection.Transform).CenterY = 3 * ActualHeight / 4;
            ((ScaleTransform)_reflection.Transform).CenterX = ActualWidth / 2;

            // draw the reflection
            drawingContext.DrawRectangle(
                _reflection, null,
                new Rect(0, ActualHeight / 2, ActualWidth, ActualHeight / 2));

            // cleanup
            drawingContext.Pop();
            drawingContext.Pop();
        }
开发者ID:nirdobovizki,项目名称:MvvmControls,代码行数:23,代码来源:ReflectionControl.cs

示例6: ApplyFilter

        /// <summary>
        /// Applies the <see cref="ShinyFloorFilter" /> to the specified <paramref name="source"/>.
        /// </summary>
        /// <param name="source">The source image.</param>
        /// <param name="dc"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        protected override void ApplyFilter(FastBitmap source, DrawingContext dc, int width, int height)
        {
            // First, draw reflected image with an opacity mask.
            int reflectionHeight = (int)(source.Height * (ReflectionPercentage / 100.0f));
            dc.PushTransform(new TransformGroup
            {
                Children = new TransformCollection
                {
                    new ScaleTransform {ScaleY = -1},
                    new TranslateTransform {Y = GetReflectionOffsetY(source) + reflectionHeight}
                }
            });
            dc.PushOpacityMask(new LinearGradientBrush(
                Colors.Transparent,
                Color.FromArgb((byte)(255.0f * (ReflectionOpacity / 100.0f)), 0, 0, 0),
                new Point(0, 0),
                new Point(0, 1)));

            dc.DrawImage(new CroppedBitmap(source.InnerBitmap, new Int32Rect(0, source.Height - reflectionHeight, source.Width, reflectionHeight)),
                new Rect(0, 0, source.Width, reflectionHeight));

            dc.Pop();
            dc.Pop();

            // Draw original image.
            dc.DrawImage(source.InnerBitmap, new Rect(0, 0, source.Width, source.Height));
        }
开发者ID:dbre2,项目名称:dynamic-image,代码行数:34,代码来源:ShinyFloorFilter.cs

示例7: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            var child = Child;
            if (child == null)
            {
                return;
            }

            if (m_brush == null)
            {
                return;
            }

            var renderSize = RenderSize;
            var childRenderSize = child.RenderSize;
            var reflectionSize = ReflectionSize;
            var reflectionSeparation = ReflectionSeparation;

            var matrix = Matrix.Identity;
            matrix.Scale(1,-1);
            matrix.Translate (0, childRenderSize.Height + reflectionSize + reflectionSeparation);

            m_transform.Matrix = matrix;

            drawingContext.PushTransform (m_transform);
            drawingContext.PushOpacityMask (m_opacityMask);

            var rectangle = new Rect(
                0,
                0,
                renderSize.Width,
                reflectionSize
                );

            drawingContext.DrawRectangle (
                m_brush,
                null,
                rectangle
                );

            drawingContext.Pop();
            drawingContext.Pop();
        }
开发者ID:mrange,项目名称:T4Include,代码行数:43,代码来源:ReflectionDecorator.cs

示例8: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            // Draw non-reflection controls
            base.OnRender(drawingContext);

            double halfHeight = ActualHeight / 2;

            // Create fading opacity mask
            drawingContext.PushOpacityMask(opacityMask);
            drawingContext.PushOpacity(0.15);

            // Create the reflection mirror transform.
            reflection.Visual = Child;
            ((ScaleTransform)reflection.Transform).CenterY = ActualHeight * 3/4;
            ((ScaleTransform)reflection.Transform).CenterX = ActualWidth / 2;

            // Draw the reflection visual with opacity mask applied
            drawingContext.DrawRectangle(
                reflection, null,
                new Rect(0, halfHeight, ActualWidth, halfHeight));

            // Remove opacity masks for next drawing
            drawingContext.Pop();
            drawingContext.Pop();
        }
开发者ID:Maloyinvestments,项目名称:sk-jukebox-prototype,代码行数:25,代码来源:ReflectionControl.cs

示例9: CreatePageVisual

 protected virtual void CreatePageVisual(Rect pageBounds, DrawingVisual source, bool isFooterPage, DrawingContext drawingContext)
 {
     drawingContext.DrawRectangle(null, FramePen, new Rect { X = FrameRect.X, Y = FrameRect.Y, Width = FrameRect.Width, Height = FrameRect.Height });
     var offsetX = PageMargins.Left - pageBounds.X - 1;
     var offsetY = PageMargins.Top - pageBounds.Y;
     drawingContext.PushTransform(new TranslateTransform(offsetX, offsetY + HeaderHeight));
     var pg = new Rect(new Point(pageBounds.X, pageBounds.Y), new Size(pageBounds.Width, pageBounds.Height));
     drawingContext.PushClip(new RectangleGeometry(pg));
     drawingContext.PushOpacityMask(Brushes.White);
     drawingContext.DrawDrawing(source.Drawing);
 }
开发者ID:serbrech,项目名称:wpfprintengine,代码行数:11,代码来源:VisualPaginator.cs

示例10: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            drawingContext.PushOpacityMask(ReflectionMask);
            drawingContext.PushOpacity(ReflectionOpacity);

            _mReflection.Visual = Child;

            ((ScaleTransform)_mReflection.Transform).CenterY = 3 * ActualHeight / 4;
            ((ScaleTransform)_mReflection.Transform).CenterX = ActualWidth / 2;

            drawingContext.DrawRectangle(_mReflection, null, new Rect(0, ActualHeight / 2, ActualWidth, ActualHeight / 2));

            drawingContext.Pop();
            drawingContext.Pop();
        }
开发者ID:HWiese1980,项目名称:HAW-Stundenplan,代码行数:17,代码来源:ReflectionControl.cs

示例11: Antialiasing

        //DepthImagePixel[] depthPixels, byte[] colorPixels,DepthImageFormat depthFormat, ColorImageFormat colorFormat)
        public void Antialiasing(DrawingContext drawingContext)
        {
            // do our processing outside of the using block
            // so that we return resources to the kinect as soon as possible
            _sensor.CoordinateMapper.MapDepthFrameToColorFrame(
                _sensor.DepthStream.Format,
                _depthPixels,
                _sensor.ColorStream.Format,
                _colorCoordinates);

            Array.Clear(_greenScreenPixelData, 0, _greenScreenPixelData.Length);

            _borderCounter = 0;

            // loop over each row and column of the depth
            for (int y = 0; y < _depthHeight; ++y)
            {
                for (int x = 0; x < _depthWidth; ++x)
                {
                    // calculate index into depth array
                    int depthIndex = x + (y * _depthWidth);

                    DepthImagePixel depthPixel = _depthPixels[depthIndex];

                    int player = depthPixel.PlayerIndex;
                    int depthDist = depthPixel.Depth;
                    // if we're tracking a player for the current pixel, do green screen
                    if (player > 0 && (depthDist > 400 && depthDist < 3500))
                    {
                        //found = true;

                        // retrieve the depth to color mapping for the current depth pixel
                        ColorImagePoint colorImagePoint = _colorCoordinates[depthIndex];

                        // scale color coordinates to depth resolution
                        int colorInDepthX = colorImagePoint.X / _colorToDepthDivisor;
                        int colorInDepthY = colorImagePoint.Y / _colorToDepthDivisor;

                        // make sure the depth pixel maps to a valid point in color space
                        // check y > 0 and y < depthHeight to make sure we don't write outside of the array
                        // check x > 0 instead of >= 0 since to fill gaps we set opaque current pixel plus the one to the left
                        // because of how the sensor works it is more correct to do it this way than to set to the right
                        if (colorInDepthX > 0 && colorInDepthX < _depthWidth && colorInDepthY >= 0 && colorInDepthY < _depthHeight)
                        {
                            // calculate index into the green screen pixel array
                            int greenScreenIndex = colorInDepthX + (colorInDepthY * _depthWidth);

                            if (_antialiasing)
                            {
                                AddBorderPixels(greenScreenIndex);
                                _greenScreenPixelData[greenScreenIndex] = OpaquePoint;
                            }
                            else
                            {

                                _greenScreenPixelData[greenScreenIndex] = OpaquePoint;
                                _greenScreenPixelData[greenScreenIndex - 1] = OpaquePoint;
                            }
                        }
                    }
                }
            }

            if (_antialiasing)
            {
                Antialiasing();
                //HidePixels();
            }

            // do our processing outside of the using block
            // so that we return resources to the kinect as soon as possible
            // Write the pixel data into our bitmap
            _colorBitmap.WritePixels(
                new Int32Rect(0, 0, _colorBitmap.PixelWidth, _colorBitmap.PixelHeight),
                _colorPixels,
                _colorBitmap.PixelWidth * sizeof(int),
                0);

            if (_playerOpacityMaskImage == null)
            {
                _playerOpacityMaskImage = new WriteableBitmap(
                    _depthWidth,
                    _depthHeight,
                    96,
                    96,
                    PixelFormats.Bgra32,
                    null);
            }

            _playerOpacityMaskImage.WritePixels(
                new Int32Rect(0, 0, _depthWidth, _depthHeight),
                _greenScreenPixelData,
                _depthWidth * ((_playerOpacityMaskImage.Format.BitsPerPixel) / 8),
                0);

            drawingContext.PushOpacityMask(new ImageBrush { ImageSource = _playerOpacityMaskImage});
            drawingContext.DrawImage(_colorBitmap, new Rect(0, 0, ActualWidth, ActualHeight));
        }
开发者ID:rechc,项目名称:KinectMiniApps,代码行数:99,代码来源:GreenScreenControl.xaml.cs


注:本文中的System.Windows.Media.DrawingContext.PushOpacityMask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。