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


C# Drawing.Size类代码示例

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


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

示例1: WarpAffine

 /// <summary>
 /// Applies an affine transformation to an image.
 /// </summary>
 /// <param name="src">Source image</param>
 /// <param name="dst">Destination image</param>
 /// <param name="mapMatrix">2x3 transformation matrix</param>
 /// <param name="dsize">Size of the output image.</param>
 /// <param name="interpMethod">Interpolation method</param>
 /// <param name="warpMethod">Warp method</param>
 /// <param name="borderMode">Pixel extrapolation method</param>
 /// <param name="borderValue">A value used to fill outliers</param>
 public static void WarpAffine(IInputArray src, IOutputArray dst, IInputArray mapMatrix, Size dsize, CvEnum.Inter interpMethod = CvEnum.Inter.Linear, CvEnum.Warp warpMethod = CvEnum.Warp.Default, CvEnum.BorderType borderMode = CvEnum.BorderType.Constant, MCvScalar borderValue = new MCvScalar())
 {
    using (InputArray iaSrc = src.GetInputArray())
    using (OutputArray oaDst = dst.GetOutputArray())
    using (InputArray iaMapMatrix = mapMatrix.GetInputArray())
       cveWarpAffine(iaSrc, oaDst, iaMapMatrix, ref dsize, (int)interpMethod | (int)warpMethod, borderMode, ref borderValue);
 }
开发者ID:Warren-GH,项目名称:emgucv,代码行数:18,代码来源:CvInvokeImgproc.cs

示例2: Resize

        public static void Resize(this Image source, String newFilename, Size newSize, long quality, ContentAlignment contentAlignment, ThumbMode mode)
        {
            Image image = source.Resize(newSize, quality, contentAlignment, mode);

            using (EncoderParameters encoderParams = new EncoderParameters(1))
            {
                using (EncoderParameter parameter = (encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, quality)))
                {
                    ImageCodecInfo encoder = null;
                    //取得擴展名
                    string ext = Path.GetExtension(newFilename);
                    if (string.IsNullOrEmpty(ext))
                        ext = ".jpg";
                    //根據擴展名得到解碼、編碼器
                    foreach (ImageCodecInfo codecInfo in ImageCodecInfo.GetImageEncoders())
                    {
                        if (Regex.IsMatch(codecInfo.FilenameExtension, string.Format(@"(;|^)\*\{0}(;|$)", ext), RegexOptions.IgnoreCase))
                        {
                            encoder = codecInfo;
                            break;
                        }
                    }

                    DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(newFilename));
                    if(dir.Exists == false) dir.Create();
                    image.Save(newFilename, encoder, encoderParams);
                }
            }
        }
开发者ID:JasonSoft,项目名称:JasonSoft,代码行数:29,代码来源:DrawingExtension.cs

示例3: ApplyFormSize

        public void ApplyFormSize(Form form)
        {
            var size = new Size(Width, Height);

            if (Screen.PrimaryScreen.WorkingArea.Height < size.Height)
            {
                size.Height = Screen.PrimaryScreen.WorkingArea.Height;
            }

            if (Screen.PrimaryScreen.WorkingArea.Width < size.Width)
            {
                size.Width = Screen.PrimaryScreen.WorkingArea.Width;
            }

            if (form.MinimumSize.Width > size.Width)
            {
                size.Width = form.MinimumSize.Width;
            }

            if (form.MinimumSize.Height > size.Height)
            {
                size.Height = form.MinimumSize.Height;
            }

            if (size.Height != 0)
            {
                form.Size = size;
                form.Top = (Screen.PrimaryScreen.WorkingArea.Height - size.Height) / 2;
                form.Left = (Screen.PrimaryScreen.WorkingArea.Width - size.Width) / 2;
            }
        }
开发者ID:RazDynamics,项目名称:XrmToolBox,代码行数:31,代码来源:Options.cs

示例4: Rectangle

 /// <summary>
 ///    <para>
 ///       Initializes a new instance of the Rectangle class with the specified location
 ///       and size.
 ///    </para>
 /// </summary>
 public Rectangle(Point location, Size size)
 {
     _x = location.X;
     _y = location.Y;
     _width = size.Width;
     _height = size.Height;
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:13,代码来源:Rectangle.cs

示例5: OSMThumbnailInfo

 public OSMThumbnailInfo(double latitude, double longitude, int zoom, Size thumbSize)
 {
     this.Latitude = latitude;
     this.Longitude = longitude;
     this.Zoom = zoom;
     this.ThumbnailSize = thumbSize;
 }
开发者ID:upsilon,项目名称:OpenTween,代码行数:7,代码来源:MapThumbOSM.cs

示例6: FullScreenCapableWindow

		/// <summary>
		/// Initializes a new instance of the FullScreenCapableWindow
		/// </summary>
		public FullScreenCapableWindow()
		{
			this.InitializeComponent();

			_size = this.Size;
			_location = this.Location;
		}
开发者ID:FireBall1725,项目名称:Razor.Framework,代码行数:10,代码来源:FullScreenCapableWindow.cs

示例7: TileCanvas

        public TileCanvas(TileLayer tileLayer)
        {
            TileLayer = tileLayer;

            //Init the textures array
            Size texSize = new Size(MAX_TEXTURE_SIZE - (MAX_TEXTURE_SIZE % TileLayer.Definition.Grid.Width), MAX_TEXTURE_SIZE - (MAX_TEXTURE_SIZE % TileLayer.Definition.Grid.Height));

            Size maxSize = new Size(TileLayer.Definition.Grid.Width * TileLayer.TileCellsX, TileLayer.Definition.Grid.Height * TileLayer.TileCellsY);

            // TODO: Clip the dimensions of the tiles that draw over the edges of the level.
            Textures = new List<TextureInfo>();
            for (int i = 0; i < maxSize.Width; i += texSize.Width)
            {
                for (int j = 0; j < maxSize.Height; j += texSize.Height)
                {
                    RenderTarget2D tex = new RenderTarget2D(
                        Ogmo.EditorDraw.GraphicsDevice,
                        Math.Min(maxSize.Width - i, texSize.Width),
                        Math.Min(maxSize.Height - j, texSize.Height));
                    Textures.Add(new TextureInfo(tex, new Point(i, j)));
                }
            }

            RefreshAll();
        }
开发者ID:hach-que,项目名称:OgmoEditor,代码行数:25,代码来源:TileCanvas.cs

示例8: Ellipse

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="point">Center</param>
 /// <param name="size">Width and height of ellipse</param>
 public Ellipse(Point point, Size size)
 {
     this.x = (short)point.X;
     this.y = (short)point.Y;
     this.radiusX = (short)size.Width;
     this.radiusY = (short)size.Height;
 }
开发者ID:Blizz9,项目名称:FanCut,代码行数:12,代码来源:Ellipse.cs

示例9: ToolBar

	private static readonly int dividerHeight = 2; // yet another guess



	// Constructor
	public ToolBar() : base()
	{
		base.Dock = DockStyle.Top;
		base.TabStop = false;
		buttons = new ToolBarButtonCollection(this);
		staticSize = DefaultSize;
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:12,代码来源:ToolBar.cs

示例10: Rectangle

 // -----------------------
 // Public Constructors
 // -----------------------
 /// <summary>
 ///	Rectangle Constructor
 /// </summary>
 ///
 /// <remarks>
 ///	Creates a Rectangle from Point and Size values.
 /// </remarks>
 public Rectangle(Point location, Size size)
 {
     x = location.X;
     y = location.Y;
     width = size.Width;
     height = size.Height;
 }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:17,代码来源:Rectangle.cs

示例11: FIARECT

 public FIARECT(Point location, Size size)
 {
     this.left = location.X;
     this.top = location.Y;
     this.right = this.left + size.Width - 1;
     this.bottom = this.top + size.Height - 1;
 }
开发者ID:glennpierce,项目名称:Fia,代码行数:7,代码来源:FreeImageAlgorithms.cs

示例12: Measure

        public override SizeF Measure(Graphics graphics)
		{
			if (this.Image != null)
			{
				SizeF size = new Size(GraphConstants.MinimumItemWidth, GraphConstants.MinimumItemHeight);

				if (this.Width.HasValue)
					size.Width = Math.Max(size.Width, this.Width.Value);
				else
					size.Width = Math.Max(size.Width, this.Image.Width);

				if (this.Height.HasValue)
					size.Height = Math.Max(size.Height, this.Height.Value);
				else
					size.Height = Math.Max(size.Height, this.Image.Height);
				
				return size;
			} else
			{
				var size = new SizeF(GraphConstants.MinimumItemWidth, GraphConstants.MinimumItemHeight);
				if (this.Width.HasValue)
					size.Width = Math.Max(size.Width, this.Width.Value);

				if (this.Height.HasValue)
					size.Height = Math.Max(size.Height, this.Height.Value);
				
				return size;
			}
		}
开发者ID:coreafive,项目名称:XLE,代码行数:29,代码来源:NodeImageItem.cs

示例13: NewResizeImage

 public static System.Drawing.Image NewResizeImage(System.Drawing.Image image, Size size, bool preserveAspectRatio = true)
 {
     int newWidth;
     int newHeight;
     if (preserveAspectRatio)
     {
         int originalWidth = image.Width;
         int originalHeight = image.Height;
         float percentWidth = (float)size.Width / (float)originalWidth;
         float percentHeight = (float)size.Height / (float)originalHeight;
         float percent = percentHeight < percentWidth ? percentHeight : percentWidth;
         newWidth = (int)(originalWidth * percent);
         newHeight = (int)(originalHeight * percent);
     }
     else
     {
         newWidth = size.Width;
         newHeight = size.Height;
     }
     System.Drawing.Image newImage = new Bitmap(newWidth, newHeight);
     using (Graphics graphics = Graphics.FromImage(newImage))
     {
         graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
         graphics.DrawImage(image, 0, 0, newWidth, newHeight);
     }
     return newImage;
 }
开发者ID:SStewart-Ebsco,项目名称:TFS-Merge,代码行数:27,代码来源:postform.aspx.cs

示例14: AddTag2

        public static void AddTag2(Graphics g, int x_pos, int y_pos, Size Canvas)
        {
            int x_scale = Canvas.Width / x_number_of_datapoints;
            int y_scale = Canvas.Height / y_number_of_datapoints;

            g.FillEllipse(tag2, (x_scale * x_pos) - diamater / 2, (y_pos * y_scale) - diamater / 2, diamater, diamater);
        }
开发者ID:r0n22,项目名称:RFID_Distance,代码行数:7,代码来源:Form_Data.cs

示例15: Thumbnails

 public Thumbnails()
 {
     SingleImage = new Size(64, 64);
     ColumnCount = 3;
     Padding = 0;
     BackGroundColor = Color.Red;
 }
开发者ID:smartbooks,项目名称:SmartUtility,代码行数:7,代码来源:Thumbnails.cs


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