本文整理汇总了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);
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
示例5: OSMThumbnailInfo
public OSMThumbnailInfo(double latitude, double longitude, int zoom, Size thumbSize)
{
this.Latitude = latitude;
this.Longitude = longitude;
this.Zoom = zoom;
this.ThumbnailSize = thumbSize;
}
示例6: FullScreenCapableWindow
/// <summary>
/// Initializes a new instance of the FullScreenCapableWindow
/// </summary>
public FullScreenCapableWindow()
{
this.InitializeComponent();
_size = this.Size;
_location = this.Location;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例15: Thumbnails
public Thumbnails()
{
SingleImage = new Size(64, 64);
ColumnCount = 3;
Padding = 0;
BackGroundColor = Color.Red;
}