本文整理汇总了C#中System.Drawing.PointF.Min方法的典型用法代码示例。如果您正苦于以下问题:C# PointF.Min方法的具体用法?C# PointF.Min怎么用?C# PointF.Min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.PointF
的用法示例。
在下文中一共展示了PointF.Min方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RotateImage
public bool RotateImage( string sourceImagePath, int rotationDegree )
{
try
{
string fileExt = Path.GetExtension( sourceImagePath ).ToLowerInvariant().Trim( '.' );
// create file name of the temp file
string tempFilePath = getTempFileName( sourceImagePath, fileExt );
using( Bitmap inputImage = new Bitmap( sourceImagePath ) )
{
EncoderParameters encParams = null;
var encoder = getEncoder( fileExt, out encParams );
// calculate width and height of the new image
float iW = (float)inputImage.Width;
float iH = (float)inputImage.Height;
Matrix whRotation = new Matrix();
whRotation.Rotate( rotationDegree );
// rotate every vertex of our "image rectangle"
var tmpDims = new PointF[] { new PointF(0,0), new PointF( iW, 0 ), new PointF( iW, iH ), new PointF( 0, iH ) };
whRotation.TransformVectors( tmpDims );
// find extends
iW = Math.Abs( tmpDims.Max( x => x.X ) - tmpDims.Min( x => x.X ) );
iH = Math.Abs( tmpDims.Max( x => x.Y ) - tmpDims.Min( x => x.Y ) );
using( Bitmap tempBmp = new Bitmap( (int)Math.Ceiling( iW ), (int)Math.Ceiling( iH ) ) )
{
// rotate image
tempBmp.SetResolution( inputImage.HorizontalResolution, inputImage.VerticalResolution );
using( Graphics g = Graphics.FromImage( tempBmp ) )
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
// rotate at the center
g.TranslateTransform( tempBmp.Width/2, tempBmp.Height/2 );
g.RotateTransform( rotationDegree );
g.TranslateTransform( -tempBmp.Width / 2, -tempBmp.Height / 2 );
g.DrawImage( inputImage,
new Point( ( tempBmp.Width - inputImage.Width ) / 2,
( tempBmp.Height - inputImage.Height ) / 2 ) );
}
tempBmp.Save( tempFilePath, encoder, encParams );
}
}
// now replace images
File.Delete( sourceImagePath );
File.Move( tempFilePath, sourceImagePath );
return true;
}
catch
{
return false;
}
}
示例2: ScaleGesture
private PointF[] ScaleGesture(PointF[] Input, int Width, int Height)
{
// Create generic list of points to hold scaled stroke
List<PointF> ScaledStroke = new List<PointF>();
// Get total width and height of gesture
float fGestureOffsetLeft = Input.Min(i => i.X);
float fGestureOffsetTop = Input.Min(i => i.Y);
float fGestureWidth = Input.Max(i => i.X) - fGestureOffsetLeft;
float fGestureHeight = Input.Max(i => i.Y) - fGestureOffsetTop;
// Get each scale ratio
double dScaleX = (double)Width / fGestureWidth;
double dScaleY = (double)Height / fGestureHeight;
// Scale on the longest axis
if (fGestureWidth >= fGestureHeight)
{
// Scale on X axis
// Clear current scaled stroke
ScaledStroke.Clear();
foreach (PointF currentPoint in Input)
ScaledStroke.Add(new PointF((float)((currentPoint.X - fGestureOffsetLeft) * dScaleX), (float)((currentPoint.Y - fGestureOffsetTop) * dScaleX)));
// Calculate new gesture width and height
_ScaledSize = new Size((int)Math.Floor(fGestureWidth * dScaleX), (int)Math.Floor(fGestureHeight * dScaleX));
}
else
{
// Scale on X axis
// Clear current scaled stroke
ScaledStroke.Clear();
foreach (PointF currentPoint in Input)
ScaledStroke.Add(new PointF((float)((currentPoint.X - fGestureOffsetLeft) * dScaleY), (float)((currentPoint.Y - fGestureOffsetTop) * dScaleY)));
// Calculate new gesture width and height
_ScaledSize = new Size((int)Math.Floor(fGestureWidth * dScaleY), (int)Math.Floor(fGestureHeight * dScaleY));
}
return ScaledStroke.ToArray();
}
示例3: FindMinX
private static float FindMinX(PointF[] bitmapRect)
{
return bitmapRect.Min(p => p.X);
}