本文整理汇总了C#中CGBitmapContext.ClosePath方法的典型用法代码示例。如果您正苦于以下问题:C# CGBitmapContext.ClosePath方法的具体用法?C# CGBitmapContext.ClosePath怎么用?C# CGBitmapContext.ClosePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGBitmapContext
的用法示例。
在下文中一共展示了CGBitmapContext.ClosePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: newImage
public static UIImage newImage(RectangleF rect,UIColor color)
{
using (var cs = CGColorSpace.CreateDeviceRGB ()){
using (var context = new CGBitmapContext (IntPtr.Zero, (int)rect.Width, (int)rect.Height, 8, (int)rect.Height*4, cs, CGImageAlphaInfo.PremultipliedLast)){
rect.X += 5;
rect.Y += 5;
rect.Width -= 10;
rect.Height -= 10;
color.SetColor ();
context.MoveTo (rect.X,rect.Y);
context.AddLineToPoint (rect.X,rect.Height);
context.AddLineToPoint (rect.Width,rect.Height);
context.AddLineToPoint (rect.Width,rect.Y);
context.ClosePath ();
context.FillPath ();
return UIImage.FromImage (context.ToImage());
}
}
}
示例2: MakeRoundCornerImage
public static UIImage MakeRoundCornerImage(UIImage img, int cornerWidth, int cornerHeight)
{
UIImage newImage = null;
if (null != img)
{
var w = img.Size.Width;
var h = img.Size.Height;
CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();
CGContext context = new CGBitmapContext(null, (int)w, (int)h, 8, (int)(4 * w), colorSpace, CGImageAlphaInfo.PremultipliedFirst);
context.BeginPath();
var rect = new RectangleF(0, 0, img.Size.Width, img.Size.Height);
AddRoundedRectToPath (context, rect, cornerWidth, cornerHeight);
context.ClosePath();
context.Clip();
var cgImage = img.CGImage;
context.DrawImage (new RectangleF(0, 0, w, h), cgImage);
cgImage.Dispose();
CGImage imageMasked = ((CGBitmapContext)context).ToImage();
context.Dispose();
colorSpace.Dispose();
newImage = new UIImage(imageMasked);
imageMasked.Dispose();
}
return newImage;
}