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


C# Drawing.Rectangle类代码示例

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


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

示例1: Evaluate

        public void Evaluate(int SpreadMax)
        {
            if (this.FOutLayer[0] == null) { this.FOutLayer[0] = new DX11Resource<DX11Layer>(); }

            if (this.FEnabled[0])
            {
                this.FLayerIn.Sync();
            }

            if (rectangles.Length != SpreadMax)
            {
                rectangles = new System.Drawing.Rectangle[SpreadMax];
            }

            for (int i = 0; i < SpreadMax; i++)
            {
                int px ,py,sx,sy;
                px = (int)FInPosition[i].X;
                py = (int)FInPosition[i].Y;
                sx = (int)FInSize[i].X;
                sy = (int)FInSize[i].Y;

                rectangles[i] = new System.Drawing.Rectangle(px, py, sx, sy);
            }
        }
开发者ID:dotprodukt,项目名称:dx11-vvvv,代码行数:25,代码来源:DX11LayerScissorNode.cs

示例2: Compare

		public float Compare (FramePixelData a, FramePixelData b)
		{
			int minWidth, maxWidth, minHeight, maxHeight;

			MathUtility.MinMax (a.Width, b.Width, out minWidth, out maxWidth);
			MathUtility.MinMax (a.Height, b.Height, out minHeight, out maxHeight);

			var rect = new System.Drawing.Rectangle (0, 0, minWidth, minHeight);

			long error = 0;

			int index = 0;
			for (int y = 0; y < rect.Height; ++y) {
				for (int x = 0; x < rect.Width; ++x) {
					error += Delta (a.Data [index], b.Data [index]);
					index++;
				}
			}

			// FIXME: To temporarily accommodate the differing
			//        resolutions of mobile platforms, we just
			//        ignore all non-overlapping pixels.  This
			//        is not ideal, but it's good enough for now.
			// Mark all out-of-bounds pixels as non-match.
			//error += PixelArgb.MaxDelta * ((maxWidth * maxHeight) - (minWidth * minHeight));

			var dissimilarity = ((float) error / (float) (PixelArgb.MaxDelta * minWidth * minHeight));

			// Project dissimilarity to a logarithmic scale.  The
			// difference between having zero pixels wrong and one
			// pixel wrong is more significant than the difference
			// betweeen 10,000 wrong and 10,001.
			return 1.0f - (float) Math.Pow (dissimilarity, 0.5);
		}
开发者ID:GhostTap,项目名称:MonoGame,代码行数:34,代码来源:PixelDeltaFrameComparer.cs

示例3: OnUpdateGeometryState

        protected override void OnUpdateGeometryState()
        {
            base.OnUpdateGeometryState();

            fGradient.SetVertices(Origin.X, Origin.Y, Frame.Width, Frame.Height);
            fBorder = new System.Drawing.Rectangle(Origin.X, Origin.Y, Frame.Width, Frame.Height);
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:7,代码来源:GradientRectangle.cs

示例4: MyGdiPlusCanvas

        //-------------------------------


        internal MyGdiPlusCanvas(
            int horizontalPageNum,
            int verticalPageNum,
            int left, int top,
            int width,
            int height)
        {


#if DEBUG
            debug_canvas_id = dbug_canvasCount + 1;
            dbug_canvasCount += 1;
#endif

            this.pageNumFlags = (horizontalPageNum << 8) | verticalPageNum;
            //2. dimension
            this.left = left;
            this.top = top;
            this.right = left + width;
            this.bottom = top + height;
            currentClipRect = new System.Drawing.Rectangle(0, 0, width, height);

            CreateGraphicsFromNativeHdc(width, height);
            this.gx = System.Drawing.Graphics.FromHdc(win32MemDc.DC);
            //-------------------------------------------------------     
            //managed object
            internalPen = new System.Drawing.Pen(System.Drawing.Color.Black);
            internalSolidBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            this.StrokeWidth = 1;
        }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:34,代码来源:1_MyGdiPlusCanvas_Specific.cs

示例5: CreateAvatar

        public static byte[] CreateAvatar(int sideLength, System.IO.Stream fromStream)
        {
            System.IO.MemoryStream ms = new System.IO.MemoryStream();

            using (var image = System.Drawing.Image.FromStream(fromStream))
            using (var thumbBitmap = new System.Drawing.Bitmap(sideLength, sideLength))
            {

                var a = Math.Min(image.Width, image.Height);

                var x = (image.Width - a) / 2;

                var y = (image.Height - a) / 2;

                using (var thumbGraph = System.Drawing.Graphics.FromImage(thumbBitmap))
                {

                    thumbGraph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                    thumbGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                    thumbGraph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                    var imgRectangle = new System.Drawing.Rectangle(0, 0, sideLength, sideLength);

                    thumbGraph.DrawImage(image, imgRectangle, x, y, a, a, System.Drawing.GraphicsUnit.Pixel);

                    thumbBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                }

            }
            return (ms.ToArray());
        }
开发者ID:kyallbarrows,项目名称:LifeguardServer,代码行数:34,代码来源:Utilities.cs

示例6: Draw

        public static void Draw( SpriteBatch spriteBatch, LevelEd level )
        {
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle( bounds.X, bounds.Y, bounds.Width, bounds.Height );
            int gridSpacing;
            if( Global.Tools.DragSnapAmount < 16 )
                gridSpacing = 16;
            else
                gridSpacing = Global.Tools.DragSnapAmount;

            line.Width = GRID_LINE_WIDTH;
            line.Y = rect.Y;
            line.Height = rect.Height;

            for( line.X = rect.X; line.X < rect.Right; line.X += gridSpacing )
                spriteBatch.Draw( Global.Pixel, line, GRID_COLOR );

            line.X = rect.X;
            line.Width = rect.Width;
            line.Height = GRID_LINE_WIDTH;

            for( line.Y = rect.Y; line.Y < rect.Bottom; line.Y += gridSpacing )
                spriteBatch.Draw( Global.Pixel, line, GRID_COLOR );

            bounds.Draw( spriteBatch, 2 );
        }
开发者ID:HaKDMoDz,项目名称:Lunar-Development-Kit,代码行数:25,代码来源:Grid.cs

示例7: Run

        public static void Run()
        {
            // ExStart:AddlnkAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            Document doc = new Document();
            Page pdfPage = doc.Pages.Add();
            System.Drawing.Rectangle drect = new System.Drawing.Rectangle();
            drect.Height = (int)pdfPage.Rect.Height;
            drect.Width = (int)pdfPage.Rect.Width;
            drect.X = 0;
            drect.Y = 0;
            Aspose.Pdf.Rectangle arect = Aspose.Pdf.Rectangle.FromRect(drect);
            ArrayList inkList = new ArrayList();
            Aspose.Pdf.Point[] arrpt = new Aspose.Pdf.Point[3];
            inkList.Add(arrpt);
            arrpt[0] = new Aspose.Pdf.Point(100, 800);
            arrpt[1] = new Aspose.Pdf.Point(200, 800);
            arrpt[2] = new Aspose.Pdf.Point(200, 700);
            InkAnnotation ia = new InkAnnotation(pdfPage, arect, inkList);
            ia.Title = "XXX";
            ia.Color = Aspose.Pdf.Color.LightBlue; // (GetColorFromString(stroke.InkColor));
            ia.CapStyle = CapStyle.Rounded;
            Border border = new Border(ia);
            border.Width = 25;
            ia.Opacity = 0.5;
            pdfPage.Annotations.Add(ia);

            dataDir = dataDir + "AddlnkAnnotation_out.pdf";
            // Save output file
            doc.Save(dataDir);
            // ExEnd:AddlnkAnnotation
            Console.WriteLine("\nlnk annotation added successfully.\nFile saved at " + dataDir);
        }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:35,代码来源:AddlnkAnnotation.cs

示例8: SetPixels

        public static void SetPixels(this EmguImage img, Rectangle area, Color[] pixels)
        {
            // Area dimensions
            int xStart = area.X;
            int xEnd   = xStart + area.Width;
            int yStart = area.Y;
            int yEnd   = yStart + area.Height;

            // Area checks
            if (xStart < 0 || xEnd > img.Width || yStart < 0 || yEnd > img.Height)
                throw new ArgumentOutOfRangeException("area", area, "The are does not fill in the image");

            if (area.Width * area.Height != pixels.Length)
                throw new ArgumentOutOfRangeException("pixels", pixels, "Invalid number of pixels");

            // Data, it's faster not to iterate over a property
            byte[,,] data = img.Data;

            // Assign color to each pixel
            for (int y = yStart; y < yEnd; y++) {
                for (int x = xStart; x < xEnd; x++) {
                    // TEMP: Swap blue and red due to odd bug of Emug.CV
                    int cIdx = (y - yStart) * area.Width + (x - xStart);
                    data[y, x, 0] = (byte)pixels[cIdx].Blue;
                    data[y, x, 1] = (byte)pixels[cIdx].Green;
                    data[y, x, 2] = (byte)pixels[cIdx].Red;
                    data[y, x, 3] = (byte)pixels[cIdx].Alpha;
                }
            }
        }
开发者ID:pleonex,项目名称:ninoimager,代码行数:30,代码来源:EmguImageExtension.cs

示例9: GetRotationFromCursor

        public static Quaternion GetRotationFromCursor(System.Drawing.Point pt, float fTrackBallRadius)
        {
            System.Drawing.Rectangle rc = new System.Drawing.Rectangle(0,0,1024,768);
            float xpos = (((2.0f * pt.X) / (rc.Right-rc.Left)) - 1);
            float ypos = (((2.0f * pt.Y) / (rc.Bottom-rc.Top)) - 1);
            float sz;

            if (xpos == 0.0f && ypos == 0.0f)
                return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);

            float d2 = (float)Math.Sqrt(xpos*xpos + ypos*ypos);

            if (d2 < fTrackBallRadius * 0.70710678118654752440) // Inside sphere
                sz = (float)Math.Sqrt(fTrackBallRadius*fTrackBallRadius - d2*d2);
            else                                                 // On hyperbola
                sz = (fTrackBallRadius*fTrackBallRadius) / (2.0f*d2);

            // Get two points on trackball's sphere
            Vector3 p1 = new Vector3(xpos, ypos, sz);
            Vector3 p2 = new Vector3(0.0f, 0.0f, fTrackBallRadius);

            // Get axis of rotation, which is cross product of p1 and p2
            Vector3 axis = Vector3.Cross(p1,p2);

            // Calculate angle for the rotation about that axis
            float t = Vector3.Length(Vector3.Subtract(p2,p1)) / (2.0f*fTrackBallRadius);
            if (t > +1.0f) t = +1.0f;
            if (t < -1.0f) t = -1.0f;
            float fAngle = (float)(2.0f * Math.Asin(t));

            // Convert axis to quaternion
            return Quaternion.RotationAxis(axis, fAngle);
        }
开发者ID:deobald,项目名称:midget,代码行数:33,代码来源:MovementFunctions.cs

示例10: Run

 public static void Run()
 {
     try
     {
         // ExStart:DigitallySignature
         string pbxFile = "";
         // The path to the documents directory.
         string dataDir = RunExamples.GetDataDir_AsposePdfFacades_SecuritySignatures();
         // Create PdfFileSignature object and bind input and output PDF files
         PdfFileSignature pdfSign = new PdfFileSignature();
         pdfSign.BindPdf(dataDir + "DigitallySign.pdf");
         // Create a rectangle for signature location
         System.Drawing.Rectangle rect = new System.Drawing.Rectangle(100, 100, 200, 100);
         // Set signature appearance
         pdfSign.SignatureAppearance = dataDir + "aspose-logo.jpg";
         // Create any of the three signature types
         PKCS1 signature = new PKCS1(pbxFile, "password"); // PKCS#1 or
         
         pdfSign.Sign(1, "Signature Reason", "Contact", "Location", true, rect, signature);
         // Save output PDF file
         pdfSign.Save(dataDir + "DigitallySignature_out.pdf");
         // ExEnd:DigitallySignature
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
开发者ID:aspose-pdf,项目名称:Aspose.Pdf-for-.NET,代码行数:28,代码来源:DigitallySignature.cs

示例11: SDXBitmapFromSysBitmap

        private SharpDX.Direct2D1.Bitmap SDXBitmapFromSysBitmap(WindowRenderTarget device, System.Drawing.Bitmap bitmap)
        {
            var sourceArea = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
            var bitmapProperties = new BitmapProperties(new PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied));
            var size = new Size2(bitmap.Width, bitmap.Height);

            // Transform pixels from BGRA to RGBA
            int stride = bitmap.Width * sizeof(int);
            using (var tempStream = new DataStream(bitmap.Height * stride, true, true))
            {
                // Lock System.Drawing.Bitmap
                var bitmapData = bitmap.LockBits(sourceArea, System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

                // Convert all pixels 
                for (int y = 0; y < bitmap.Height; y++)
                {
                    int offset = bitmapData.Stride * y;
                    for (int x = 0; x < bitmap.Width; x++)
                    {
                        // Not optimized 
                        byte B = Marshal.ReadByte(bitmapData.Scan0, offset++);
                        byte G = Marshal.ReadByte(bitmapData.Scan0, offset++);
                        byte R = Marshal.ReadByte(bitmapData.Scan0, offset++);
                        byte A = Marshal.ReadByte(bitmapData.Scan0, offset++);
                        int rgba = R | (G << 8) | (B << 16) | (A << 24);
                        tempStream.Write(rgba);
                    }

                }
                bitmap.UnlockBits(bitmapData);
                tempStream.Position = 0;

                return new SharpDX.Direct2D1.Bitmap(device, size, tempStream, stride, bitmapProperties);
            }
        }
开发者ID:nkarpey,项目名称:Zat-s-External-CSGO-Multihack,代码行数:35,代码来源:ESP.cs

示例12: DirectXTexture

        /// <summary>
        /// Initializes a new DirectXTexture class.
        /// </summary>
        /// <param name="bmp">The Bitmap.</param>
        internal DirectXTexture(System.Drawing.Bitmap bmp)
        {
            RawBitmap = (System.Drawing.Bitmap) bmp.Clone();
            _width = bmp.Width;
            _height = bmp.Height;
            var sourceArea = new Rectangle(0, 0, bmp.Width, bmp.Height);
            var bitmapProperties = new BitmapProperties(
                new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied), 96, 96);
            var size = new Size2(bmp.Width, bmp.Height);

            int stride = bmp.Width*sizeof (int);
            using (var tempStream = new DataStream(bmp.Height*stride, true, true))
            {
                BitmapData bitmapData = bmp.LockBits(sourceArea, ImageLockMode.ReadOnly,
                    System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

                for (int y = 0; y < bmp.Height; y++)
                {
                    int offset = bitmapData.Stride*y;
                    for (int x = 0; x < bmp.Width; x++)
                    {
                        byte b = Marshal.ReadByte(bitmapData.Scan0, offset++);
                        byte g = Marshal.ReadByte(bitmapData.Scan0, offset++);
                        byte r = Marshal.ReadByte(bitmapData.Scan0, offset++);
                        byte a = Marshal.ReadByte(bitmapData.Scan0, offset++);
                        int rgba = r | (g << 8) | (b << 16) | (a << 24);
                        tempStream.Write(rgba);
                    }
                }
                bmp.UnlockBits(bitmapData);
                tempStream.Position = 0;
                _bmp = new Bitmap(DirectXHelper.RenderTarget, size, tempStream, stride, bitmapProperties);
            }
        }
开发者ID:ThuCommix,项目名称:Sharpex2D,代码行数:38,代码来源:DirectXTexture.cs

示例13: huoqupingmutuxing

        internal Texture2D huoqupingmutuxing(int x, int y, int w, int h,GraphicsDevice device)
        {
             //剪切大小

 

             System.Drawing.Graphics g;

             //以大小为剪切大小,像素格式为32位RGB创建一个位图对像

             System.Drawing.Bitmap bm1 = new System.Drawing.Bitmap(w,h,System.Drawing.Imaging.PixelFormat.Format24bppRgb) ;

            //定义一个区域

             System.Drawing.Rectangle rg = new System.Drawing.Rectangle(x,y,w,h);

             //要绘制到的位图

             g = System.Drawing.Graphics.FromImage(bm1);

             //将bm内rg所指定的区域绘制到bm1

             g.DrawImage(bm, new System.Drawing.Rectangle(0, 0, w, h), rg, System.Drawing.GraphicsUnit.Pixel);


            return BitmapToTexture2D(device ,bm1);


        }
开发者ID:skicean,项目名称:ZhongHuaSanGuoZhi,代码行数:29,代码来源:beijingtupian.cs

示例14: add_anchor_window

        private void add_anchor_window(System.Windows.Forms.Form form)
        {
            var application = this.Application;
            var parent_window = application.ActiveWindow;
            if (parent_window == null)
            {
                return;
            }
            if (application.ActiveDocument == null)
            {
                return;
            }

            object window_states = IVisio.VisWindowStates.visWSFloating | IVisio.VisWindowStates.visWSVisible;
            object window_types = IVisio.VisWinTypes.visAnchorBarAddon;

            var displacement = new System.Drawing.Point(50, 100);
            var window_rect = new System.Drawing.Rectangle(displacement, form.Size);
            string window_caption = form.Text;

            var the_anchor_window = VA.Application.UserInterfaceHelper.AddAnchorWindow(parent_window,
                                                                                       window_caption,
                                                                                       window_states,
                                                                                       window_types,
                                                                                       window_rect);

            if (the_anchor_window != null)
            {
                VA.Application.UserInterfaceHelper.AttachWindowsForm(the_anchor_window, form);
                form.Refresh();
            }
        }
开发者ID:firestream99,项目名称:VisioAutomation,代码行数:32,代码来源:AddIn_customize.cs

示例15: SomeClass

        public static void SomeClass()
        {
            var graph = new MSAGL.Drawing.Graph("");
            graph.AddEdge("A", "B");
            graph.AddEdge("A", "B");
            graph.FindNode("A").Attr.FillColor = MSAGL.Drawing.Color.BlanchedAlmond;
            graph.FindNode("B").Attr.FillColor = MSAGL.Drawing.Color.BurlyWood;
            var renderer = new MSAGL.GraphViewerGdi.GraphRenderer(graph);
            renderer.CalculateLayout();
            const int width = 50;
            int height = (int)(graph.Height * (width / graph.Width));
            const PixelFormat pixfmt = System.Drawing.Imaging.PixelFormat.Format32bppPArgb;
            using (var bitmap = new System.Drawing.Bitmap(width, height, pixfmt))
            {
                using (var gfx = System.Drawing.Graphics.FromImage(bitmap))
                {
                    gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                    gfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                    gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                    var rect = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
                    renderer.Render(gfx, rect);
                    bitmap.Save("test.png");

                }

            }
           
        }
开发者ID:Exclr8,项目名称:CloudCore,代码行数:29,代码来源:MsaglGraph.cs


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