System.Drawing.Drawing2D.GraphicsPath.AddRectangle C# (CSharp) Method

AddRectangle() public method

public AddRectangle ( Rectangle rect ) : void
rect Rectangle
return void
        public void AddRectangle(Rectangle rect)
        {
            if (rect.Width == 0 || rect.Height == 0)
                return;

            Append (rect.X, rect.Y, PathPointType.Start, false);
            Append (rect.Right, rect.Y, PathPointType.Line, false);
            Append (rect.Right, rect.Bottom, PathPointType.Line, false);
            Append (rect.X, rect.Bottom, PathPointType.Line | PathPointType.CloseSubpath, false);
        }

Same methods

GraphicsPath::AddRectangle ( RectangleF rect ) : void

Usage Example

Exemplo n.º 1
1
		// From http://edu.cnzz.cn/show_3281.html
		public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent) 
		{ 
			GraphicsPath graphicsPath = new GraphicsPath(); 
			if (colorTransparent == Color.Empty)
				colorTransparent = bitmap.GetPixel(0, 0); 

			for(int row = 0; row < bitmap.Height; row ++) 
			{ 
				int colOpaquePixel = 0;
				for(int col = 0; col < bitmap.Width; col ++) 
				{ 
					if(bitmap.GetPixel(col, row) != colorTransparent) 
					{ 
						colOpaquePixel = col; 
						int colNext = col; 
						for(colNext = colOpaquePixel; colNext < bitmap.Width; colNext ++) 
							if(bitmap.GetPixel(colNext, row) == colorTransparent) 
								break;
 
						graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1)); 
						col = colNext; 
					} 
				} 
			} 
			return graphicsPath; 
		} 
All Usage Examples Of System.Drawing.Drawing2D.GraphicsPath::AddRectangle