當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。