當前位置: 首頁>>代碼示例>>C#>>正文


C# Image.GetClip方法代碼示例

本文整理匯總了C#中System.Image.GetClip方法的典型用法代碼示例。如果您正苦於以下問題:C# Image.GetClip方法的具體用法?C# Image.GetClip怎麽用?C# Image.GetClip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Image的用法示例。


在下文中一共展示了Image.GetClip方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RenderCorner

        /// <summary>
        /// Renders a corner gradient between the given colors. Includes outColor in the gradient but not inColor.
        /// </summary>
        /// <param name="image">The image to render to.</param>
        /// <param name="reverseX">True to reverse the gradient in the x direction.</param>
        /// <param name="reverseY">True to reverse the gradient in the y direction.</param>
        /// <param name="area">The area to fill.</param>
        /// <param name="outColor">The "outer" color.</param>
        /// <param name="inColor">The "inner" color.</param>
        /// <param name="roundEdges">True to round the corner, false for square.</param>
        /// <param name="interp">The interpolation function to use.</param>
        private static void RenderCorner(Image image, bool reverseX, bool reverseY, Rectangle area, ARGB outColor, ARGB inColor, bool roundEdges, InterpFunction interp)
        {
            Rectangle clip = ShapeUtil.Overlap((Rectangle)image.Size, image.GetClip(), area);
            if(clip.IsValid())
            {
                for(int i = clip.Min.X; i <= clip.Max.X; i++)
                {
                    for(int j = clip.Min.Y; j <= clip.Max.Y; j++)
                    {
                        double dx;
                        double dy;
                        if(reverseX) dx = i - area.Min.X;
                        else 		 dx = area.Max.X - i;
                        if(reverseY) dy = j - area.Min.Y;
                        else 		 dy = area.Max.Y - j;
                        dx++;
                        dx /= area.Width;
                        dy++;
                        dy /= area.Height;

                        double mu;
                        if(roundEdges)
                        {
                            mu = Math.Sqrt(dx * dx + dy * dy);
                        }else
                        {
                            mu = Math.Max(Math.Abs(dx), Math.Abs(dy));
                        }
                        mu = Util.Clip(mu, 0, 1);

                        image[i, j] = ColorUtil.Interpolate(inColor, outColor, mu, interp);
                    }
                }
            }
        }
開發者ID:jonhartnett,項目名稱:IROM-UI,代碼行數:46,代碼來源:RenderUtil.cs

示例2: RenderYSide

 /// <summary>
 /// Renders a y-oriented gradient between the given colors. Includes outColor in the gradient but not inColor.
 /// </summary>
 /// <param name="image">The image to render to.</param>
 /// <param name="reverse">True to reverse the gradient.</param>
 /// <param name="area">The area to fill.</param>
 /// <param name="outColor">The "outer" color.</param>
 /// <param name="inColor">The "inner" color.</param>
 /// <param name="interp">The interpolation function to use.</param>
 private static void RenderYSide(Image image, bool reverse, Rectangle area, ARGB outColor, ARGB inColor, InterpFunction interp)
 {
     Rectangle clip = ShapeUtil.Overlap((Rectangle)image.Size, image.GetClip(), area);
     if(clip.IsValid())
     {
         for(int j = clip.Min.Y; j <= clip.Max.Y; j++)
         {
             double mu;
             if(reverse) mu = j - area.Min.Y;
             else 		mu = area.Max.Y - j;
             mu++;
             mu /= area.Height;
             mu = Util.Clip(mu, 0, 1);
             image.RenderSolid(new Rectangle{Min = new Point2D(clip.Min.X, j), Max = new Point2D(clip.Max.X, j)}, ColorUtil.Interpolate(inColor, outColor, mu, interp));
         }
     }
 }
開發者ID:jonhartnett,項目名稱:IROM-UI,代碼行數:26,代碼來源:RenderUtil.cs


注:本文中的System.Image.GetClip方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。