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


C# PointF.Min方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:khushbug-optimus,项目名称:Hackathon,代码行数:54,代码来源:DefaultImageEditorService.cs

示例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();
        }
开发者ID:floatas,项目名称:highsign,代码行数:43,代码来源:GestureThumbnail.cs

示例3: FindMinX

 private static float FindMinX(PointF[] bitmapRect)
 {
     return bitmapRect.Min(p => p.X);
 }
开发者ID:RIT-Tool-Time,项目名称:Cascade,代码行数:4,代码来源:Picture.cs


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