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


C# Rectangle.Intersect方法代码示例

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


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

示例1: controller_NewFrame

        void controller_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            if (!backproj)
            {
                Bitmap image = eventArgs.Frame;

                if (image == null)
                    return;

                if (parent.faceForm != null && !parent.faceForm.IsDisposed)
                {
                    MatchingTracker matching = parent.faceForm.faceController.Tracker as MatchingTracker;

                    Rectangle rect = new Rectangle(
                        matching.TrackingObject.Center.X,
                        0,
                        image.Width - matching.TrackingObject.Center.X,
                        matching.TrackingObject.Center.Y);

                 
                    rect.Intersect(new Rectangle(0, 0, image.Width, image.Height));

                     marker.Rectangles = new[] { matching.TrackingObject.Rectangle };
                     image = marker.Apply(image);
                }


                pictureBox.Image = image;
            }
        }
开发者ID:BiYiTuan,项目名称:framework,代码行数:30,代码来源:VisionForm.cs

示例2: AddApron

        protected virtual Rectangle AddApron(Rectangle rect, int apronRadius, Rectangle maxBounds)
        {
            rect.Inflate(apronRadius, apronRadius);
            rect.Intersect(maxBounds);

            return rect;
        }
开发者ID:bbowyersmyth,项目名称:ComputeShaderEffects,代码行数:7,代码来源:TiledComputeShaderBase.cs

示例3: BucketWorker

        public BucketWorker(Rectangle imgPlaneRect, Rectangle bucketRect, Display display, IPixelSampler pixelSampler, Scene scene, ManualResetEvent doneEvent)
        {
            _doneEvent = doneEvent;

            m_pixelSampler = pixelSampler;
            m_scene = scene;
            m_imgPlaneRect = imgPlaneRect;
            m_bucketRect = bucketRect;
            m_bucketRect.Intersect(imgPlaneRect);
            m_display = display;
        }
开发者ID:Didoman87,项目名称:RayTracer_Lecture5_Kontrolna,代码行数:11,代码来源:ImageSamplerBuckets.cs

示例4: TransparentCommandBarControl_Invalidated

 private void TransparentCommandBarControl_Invalidated(object sender, InvalidateEventArgs e)
 {
     Point absLoc = _parent.PointToScreen(e.InvalidRect.Location);
     Point relLoc = PointToClient(absLoc);
     Rectangle relRect = new Rectangle(relLoc, e.InvalidRect.Size);
     if (ClientRectangle.IntersectsWith(relRect))
     {
         relRect.Intersect(ClientRectangle);
         Invalidate(relRect);
     }
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:11,代码来源:TransparentCommandBarControl.cs

示例5: OnDrawFinal

        public override void OnDrawFinal(Graphics g, Bitmap bmp)
        {
            Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
            rect.Intersect(Rectangle);

            using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, rect))
            {
                ImageHelpers.HighlightImage(croppedImage, HighlightColor);

                g.DrawImage(croppedImage, rect);
            }
        }
开发者ID:ElectronicWar,项目名称:ShareX,代码行数:12,代码来源:HighlightEffectShape.cs

示例6: gauge_Paint

 private void gauge_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
 {
     e.Graphics.Clear(Label.DefaultBackColor);
        Pen pen = new Pen(Color.Black);
        e.Graphics.DrawRectangle(pen, gauge.ClientRectangle);
        if (maxValue != 0)
        {
     int fillLevel = (int)((used/maxValue) * gauge.Size.Height);
     SolidBrush brush = new SolidBrush(barColor);
     Rectangle rect = new Rectangle(0, gauge.ClientSize.Height - fillLevel, gauge.ClientSize.Width, fillLevel);
     rect.Intersect(e.ClipRectangle);
     e.Graphics.FillRectangle(brush, rect);
        }
 }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:14,代码来源:GaugeChart.cs

示例7: OnDrawFinal

        public override void OnDrawFinal(Graphics g, Bitmap bmp)
        {
            if (PixelSize > 1)
            {
                Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
                rect.Intersect(Rectangle);

                using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, rect))
                {
                    ImageHelpers.Pixelate(croppedImage, PixelSize);

                    g.DrawImage(croppedImage, rect);
                }
            }
        }
开发者ID:L1Q,项目名称:ShareX,代码行数:15,代码来源:PixelateEffectShape.cs

示例8: OnDrawFinal

        public override void OnDrawFinal(Graphics g, Bitmap bmp)
        {
            if (BlurRadius > 1)
            {
                Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
                rect.Intersect(Rectangle);

                using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, rect))
                {
                    ImageHelpers.BoxBlur(croppedImage, BlurRadius);

                    g.DrawImage(croppedImage, rect);
                }
            }
        }
开发者ID:L1Q,项目名称:ShareX,代码行数:15,代码来源:BlurEffectShape.cs

示例9: SetBounds

		private bool SetBounds(Form form, ref Rectangle rectBounds)
		{
			// do this in such a way that we take into consideration the size of the screen
			//  which may not be the same from machine to machine
			bool bChanged = false;
			Rectangle rectScreen = Screen.PrimaryScreen.WorkingArea;
			if (!rectScreen.Contains(rectBounds))
			{
				rectBounds.Intersect(rectScreen);
				bChanged = true;
			}

			form.Bounds = rectBounds;
			return bChanged;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:15,代码来源:TECkit+Mapping+Editor.cs

示例10: OnPaint

 protected override void OnPaint(PaintEventArgs pe)
 {
     //these settings aren't even needed for good perf, but they are helpful
     pe.Graphics.InterpolationMode = InterpolationMode.Low;
     pe.Graphics.CompositingQuality = CompositingQuality.HighSpeed;
     pe.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
     if (this.image != null) {
         //draw empty area, if it exists, in an optimized way.
         if (this.AutoScrollPosition.X == 0) {
             int emptyRightAreaWidth = this.Width - this.image.Width;
             if (emptyRightAreaWidth > 0) {
                 Rectangle fillRect = new Rectangle(this.image.Width, 0, emptyRightAreaWidth, this.Height);
                 fillRect.Intersect(pe.ClipRectangle);
                 pe.Graphics.FillRectangle(SystemBrushes.Control, fillRect);
             }
         }
         if (this.AutoScrollPosition.Y == 0) {
             int emptyRightAreaHeight = this.Height - this.image.Height;
             if (emptyRightAreaHeight > 0) {
                 Rectangle fillRect = new Rectangle(0, this.image.Height, this.Width, emptyRightAreaHeight);
                 fillRect.Intersect(pe.ClipRectangle);
                 pe.Graphics.FillRectangle(SystemBrushes.Control, fillRect);
             }
         }
         //calculate the visible area of the bitmap
         Rectangle bitmapRect = new Rectangle(this.AutoScrollPosition.X, this.AutoScrollPosition.Y,
                                              this.image.Width, this.image.Height);
         Rectangle visibleClientRect = bitmapRect;
         visibleClientRect.Intersect(pe.ClipRectangle);
         if (visibleClientRect.Width == 0 || visibleClientRect.Height == 0) {
             return;
         }
         Rectangle visibleBitmapRect = visibleClientRect;
         visibleBitmapRect.Offset(-this.AutoScrollPosition.X, -this.AutoScrollPosition.Y);
         pe.Graphics.DrawImage(this.image, visibleClientRect, visibleBitmapRect, GraphicsUnit.Pixel);
     } else //if no bitmap just fill with background color
     {
         pe.Graphics.FillRectangle(SystemBrushes.Control, pe.ClipRectangle);
     }
 }
开发者ID:hksonngan,项目名称:sharptracing,代码行数:40,代码来源:PicturePanel.cs

示例11: RenderOneToOne

        public static void RenderOneToOne(Surface dst, Surface source, Point offset)
        {
            unsafe
            {
                Rectangle srcRect = new Rectangle(offset, dst.Size);
                srcRect.Intersect(source.Bounds);

                for (int dstRow = 0; dstRow < srcRect.Height; ++dstRow)
                {
                    ColorBgra* dstRowPtr = dst.GetRowAddressUnchecked(dstRow);
                    ColorBgra* srcRowPtr = source.GetPointAddressUnchecked(offset.X, dstRow + offset.Y);

                    int dstCol = offset.X;
                    int dstColEnd = offset.X + srcRect.Width;
                    int checkerY = dstRow + offset.Y;

                    while (dstCol < dstColEnd)
                    {
                        int b = srcRowPtr->B;
                        int g = srcRowPtr->G;
                        int r = srcRowPtr->R;
                        int a = srcRowPtr->A;

                        // Blend it over the checkerboard background
                        int v = (((dstCol ^ checkerY) & 8) << 3) + 191;
                        a = a + (a >> 7);
                        int vmia = v * (256 - a);

                        r = ((r * a) + vmia) >> 8;
                        g = ((g * a) + vmia) >> 8;
                        b = ((b * a) + vmia) >> 8;

                        dstRowPtr->Bgra = (uint)b + ((uint)g << 8) + ((uint)r << 16) + ((uint)255 << 24);
                        ++dstRowPtr;
                        ++srcRowPtr;
                        ++dstCol;
                    }
                }
            }
        }
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:40,代码来源:SurfaceBoxBaseRenderer.cs

示例12: DetectEdgesCollision

    public static Edges DetectEdgesCollision(Rectangle a, Rectangle b)
    {
        var result = Edges.None;

        if (a == b) return Edges.Identical;
        b.Intersect(a);
        if (b.IsEmpty) return Edges.None;
        if (a == b) return Edges.Covers;


        if (a.Top == b.Top && (a.Right >= b.Right && a.Left <= b.Left))
            result |= Edges.Top;
        if (a.Bottom == b.Bottom && (a.Right >= b.Right && a.Left <= b.Left))
            result |= Edges.Bottom;
        if (a.Left == b.Left && (a.Bottom >= b.Bottom && a.Top <= b.Top))
            result |= Edges.Left;
        if (a.Right == b.Right && (a.Bottom >= b.Bottom && a.Top <= b.Top))
            result |= Edges.Right;


        return result == Edges.None ? Edges.Inside : result;
    }
开发者ID:afrog33k,项目名称:eAd,代码行数:22,代码来源:EdgeDetection.cs

示例13: PixBlt

        public virtual void PixBlt(IPixelArray pixArray, int x, int y)
        {
            // 1. Calculate the intersection intended destination rectangle
            // of the pixArray and the boundary of the pixelArray we're
            // holding onto.
            Rectangle srcRect = new Rectangle(x, y, pixArray.Width, pixArray.Height);

            // Create the boundary rectangle for our destination
            Rectangle dstRect = new Rectangle(0, 0, fDstAccess.Width, fDstAccess.Height);

            // Create the intersection of the dstRect and the srcRect
            srcRect.Intersect(dstRect);

            // If there is no intersection, then just return
            if (srcRect.IsEmpty)
                return;

            Rectangle srcBoundary = srcRect;
            srcBoundary.Offset(-x, -y);
            PixmapShardBlt(pixArray, srcBoundary, srcRect);

        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:22,代码来源:RenderPixelBuffer.cs

示例14: AddPixelRangeToRefreshQueue

        public void AddPixelRangeToRefreshQueue(Rectangle pixelRange, bool cascadeToOtherMatrixes)
        {
            // limit refresh range to screen resolution
            pixelRange.Intersect(VisibleSurfaces.MaxSurfaceSize);

            // cascade to other refresh queues if required
            if (cascadeToOtherMatrixes)
            {
                if (RefreshQueueAreaAdded != null)
                    RefreshQueueAreaAdded(new RefreshQueueAreaAddedEventArgs(_layer, pixelRange));
            }

            // check all existing pixel ranges for an overlap with the new range
            for (int i = 0; i < _rects.Count; i++)
            {
                // if this pixel range is already included, just return
                if (_rects[i].Contains(pixelRange))
                    return;
            }

            // if we make it this far, this includes a new area to refresh
            isDirty = true;
            _rects.Add(pixelRange);
        }
开发者ID:Isthimius,项目名称:Gondwana,代码行数:24,代码来源:RefreshQueue.cs

示例15: PaintCurrentBytesSign

        private void PaintCurrentBytesSign(Graphics g)
        {
            if (_keyInterpreter != null && Focused && _bytePos != -1 && Enabled)
            {
                if (_keyInterpreter.GetType() == typeof (KeyInterpreter))
                {
                    if (_selectionLength == 0)
                    {
                        Point gp = GetGridBytePoint(_bytePos - _startByte);
                        PointF pf = GetByteStringPointF(gp);
                        var s = new Size((int) _charSize.Width, (int) _charSize.Height);
                        var r = new Rectangle((int) pf.X, (int) pf.Y, s.Width, s.Height);
                        if (r.IntersectsWith(_recStringView))
                        {
                            r.Intersect(_recStringView);
                            PaintCurrentByteSign(g, r);
                        }
                    }
                    else
                    {
                        var lineWidth = (int) (_recStringView.Width - _charSize.Width);

                        Point startSelGridPoint = GetGridBytePoint(_bytePos - _startByte);
                        PointF startSelPointF = GetByteStringPointF(startSelGridPoint);

                        Point endSelGridPoint = GetGridBytePoint(_bytePos - _startByte + _selectionLength - 1);
                        PointF endSelPointF = GetByteStringPointF(endSelGridPoint);

                        int multiLine = endSelGridPoint.Y - startSelGridPoint.Y;
                        if (multiLine == 0)
                        {
                            var singleLine = new Rectangle(
                                (int) startSelPointF.X,
                                (int) startSelPointF.Y,
                                (int) (endSelPointF.X - startSelPointF.X + _charSize.Width),
                                (int) _charSize.Height);
                            if (singleLine.IntersectsWith(_recStringView))
                            {
                                singleLine.Intersect(_recStringView);
                                PaintCurrentByteSign(g, singleLine);
                            }
                        }
                        else
                        {
                            var firstLine = new Rectangle(
                                (int) startSelPointF.X,
                                (int) startSelPointF.Y,
                                (int) (_recStringView.X + lineWidth - startSelPointF.X + _charSize.Width),
                                (int) _charSize.Height);
                            if (firstLine.IntersectsWith(_recStringView))
                            {
                                firstLine.Intersect(_recStringView);
                                PaintCurrentByteSign(g, firstLine);
                            }

                            if (multiLine > 1)
                            {
                                var betweenLines = new Rectangle(
                                    _recStringView.X,
                                    (int) (startSelPointF.Y + _charSize.Height),
                                    (_recStringView.Width),
                                    (int) (_charSize.Height*(multiLine - 1)));
                                if (betweenLines.IntersectsWith(_recStringView))
                                {
                                    betweenLines.Intersect(_recStringView);
                                    PaintCurrentByteSign(g, betweenLines);
                                }
                            }

                            var lastLine = new Rectangle(
                                _recStringView.X,
                                (int) endSelPointF.Y,
                                (int) (endSelPointF.X - _recStringView.X + _charSize.Width),
                                (int) _charSize.Height);
                            if (lastLine.IntersectsWith(_recStringView))
                            {
                                lastLine.Intersect(_recStringView);
                                PaintCurrentByteSign(g, lastLine);
                            }
                        }
                    }
                }
                else
                {
                    if (_selectionLength == 0)
                    {
                        Point gp = GetGridBytePoint(_bytePos - _startByte);
                        PointF pf = GetBytePointF(gp);
                        var s = new Size((int) _charSize.Width*2, (int) _charSize.Height);
                        var r = new Rectangle((int) pf.X, (int) pf.Y, s.Width, s.Height);
                        PaintCurrentByteSign(g, r);
                    }
                    else
                    {
                        var lineWidth = (int) (_recHex.Width - _charSize.Width*5);

                        Point startSelGridPoint = GetGridBytePoint(_bytePos - _startByte);
                        PointF startSelPointF = GetBytePointF(startSelGridPoint);

                        Point endSelGridPoint = GetGridBytePoint(_bytePos - _startByte + _selectionLength - 1);
//.........这里部分代码省略.........
开发者ID:rxantos,项目名称:tesv-snip,代码行数:101,代码来源:HexBox.cs


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