• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Drawing.Size类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ResizeLayer

 /// <summary>
 /// Initializes a new instance of the <see cref="ResizeLayer"/> class.
 /// </summary>
 /// <param name="size">
 /// The <see cref="T:System.Drawing.Size"/> containing the width and height to set the image to.
 /// </param>
 /// <param name="resizeMode">
 /// The <see cref="ResizeMode"/> to apply to resized image.
 /// </param>
 public ResizeLayer(Size size, ResizeMode resizeMode)
 {
     this.Size = size;
     this.ResizeMode = resizeMode;
     this.AnchorPosition = AnchorPosition.Center;
     this.BackgroundColor = Color.Transparent;
 }
开发者ID:rosrosros,项目名称:ImageProcessor,代码行数:16,代码来源:ResizeLayer.cs


示例17: GetCharacterSize

        public virtual Size GetCharacterSize( Graphics g, Font font, CharacterCasing casing )
        {
            const int MeasureCharCount = 10;

             Size charSize = new Size( 0, 0 );

             for ( char c = '0'; c <= '9'; ++c )
             {
            Size newSize = TextRenderer.MeasureText( g, new string( c, MeasureCharCount ), font, new Size( 0, 0 ),
               _textFormatFlags );

            newSize.Width = (int)Math.Ceiling( (double)newSize.Width / (double)MeasureCharCount );

            if ( newSize.Width > charSize.Width )
            {
               charSize.Width = newSize.Width;
            }

            if ( newSize.Height > charSize.Height )
            {
               charSize.Height = newSize.Height;
            }
             }

             return charSize;
        }
开发者ID:EddyBeaupre,项目名称:WinCDP-GUI,代码行数:26,代码来源:DecimalValue.cs


示例18: Main

 static void Main(string[] args)
 {
     var image = Image.FromFile("source.jpg");
     var size = new Size(100, 150);
     var resized = ResizeImage(image, size);
     resized.Save("resized.jpg", ImageFormat.Jpeg);
 }
开发者ID:paulomouat,项目名称:spikes,代码行数:7,代码来源:Program.cs


示例19: butFind_Click

        private void butFind_Click(object sender, EventArgs e)
        {
            Size = new Size(550, 500);
            string sql = String.Format( "from ForlabSite s where s.SiteName like '{0}%'", txtSitename.Text.Trim());

            if (rdbRegion.Checked)
            {
                if (lsvRegion.CheckedItems.Count > 0)
                {
                    string str = "";
                    foreach (ListViewItem li in lsvRegion.CheckedItems)
                    {
                        if (str != "")
                            str += ", " + (int)li.Tag;
                        else
                            str = li.Tag.ToString();
                    }

                    sql += " and s.Region.Id in (" + str + ")";
                }
            }
            else if (txtSitename.Text.Trim() == "")
            {
                sql = String.Format("from ForlabSite s");
            }

            BindSites(sql);
        }
开发者ID:opianHealth,项目名称:ForLAB,代码行数:28,代码来源:FrmSearchSite.cs


示例20: GetNextPoint

        public unsafe Point GetNextPoint(Rectangle rectTrack, byte* pIn, Size sizeIn, double[] Qu, double[] PuY0)
        {
            double[] w = new double[256];//方向权值
            for (int i = 0; i < 256; i++)
            {
                w[i] = Math.Sqrt(Qu[i] / PuY0[i]);
            }

            PointF center = new PointF(
                (float)rectTrack.Left + (float)rectTrack.Width / 2,
                (float)rectTrack.Top + (float)rectTrack.Height / 2);
            SizeF H = new SizeF((float)rectTrack.Width / 2, (float)rectTrack.Height / 2);
            double numeratorX = 0, numeratorY = 0;//分子
            double denominatorX = 0, denominatorY = 0;//分母
            for (int y = rectTrack.Top; y < rectTrack.Bottom; y++)
            {
                for (int x = rectTrack.Left; x < rectTrack.Right; x++)
                {
                    int index = DataManager.GetIndex(x, y, sizeIn.Width);
                    byte u = pIn[index];
                    //计算以高斯分布为核函数自变量X的值
                    double X = ((Math.Pow((x - center.X), 2) + Math.Pow((y - center.Y), 2))
                            / (Math.Pow(H.Width, 2) + Math.Pow(H.Height, 2)));
                    //负的高斯分布核函数的值
                    double Gi = -Math.Exp(-Math.Pow(X, 2) / 2) / Math.Sqrt(2 * Math.PI);

                    numeratorX += x * w[u] * Gi;
                    numeratorY += y * w[u] * Gi;
                    denominatorX += w[u] * Gi;
                    denominatorY += w[u] * Gi;
                }
            }
            return new Point((int)(numeratorX / denominatorX), (int)(numeratorY / denominatorY));
        }
开发者ID:dalinhuang,项目名称:my-computer-vision,代码行数:34,代码来源:MeanShift.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Drawing.SizeF类代码示例发布时间:2022-05-26
下一篇:
C# Drawing.Region类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap