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


C# UIImage.InvokeOnMainThread方法代码示例

本文整理汇总了C#中UIImage.InvokeOnMainThread方法的典型用法代码示例。如果您正苦于以下问题:C# UIImage.InvokeOnMainThread方法的具体用法?C# UIImage.InvokeOnMainThread怎么用?C# UIImage.InvokeOnMainThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIImage的用法示例。


在下文中一共展示了UIImage.InvokeOnMainThread方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Scale

		public static UIImage Scale(UIImage image, float maxWidthAndHeight)
		{
			//Perform Image manipulation, make the image fit into a 48x48 tile without clipping.  
			
			UIImage scaledImage = image;
			
			image.InvokeOnMainThread(() => {
				float fWidth = image.Size.Width;
				float fHeight = image.Size.Height;
				float fTotal = fWidth>=fHeight?fWidth:fHeight;
				float fDifPercent = maxWidthAndHeight / fTotal;
				float fNewWidth = fWidth*fDifPercent;
				float fNewHeight = fHeight*fDifPercent;
				
				SizeF newSize = new SizeF(fNewWidth,fNewHeight);
				
				UIGraphics.BeginImageContext (newSize);
		        var context = UIGraphics.GetCurrentContext ();
		        context.TranslateCTM (0, newSize.Height);
		        context.ScaleCTM (1f, -1f);
		
		        context.DrawImage (new RectangleF (0, 0, newSize.Width, newSize.Height), image.CGImage);
		
		        scaledImage = UIGraphics.GetImageFromCurrentImageContext();
		        UIGraphics.EndImageContext();
			});
			
			return scaledImage;
		}
开发者ID:Redth,项目名称:MonoTouch.UrlImageStore,代码行数:29,代码来源:Graphics.cs

示例2: RoundCorners

        public static UIImage RoundCorners (UIImage image, int radius)
        {
			if (image == null)
				throw new ArgumentNullException ("image");
			
			UIImage converted = image;
			
			image.InvokeOnMainThread(() => {
	            UIGraphics.BeginImageContext (image.Size);
				float imgWidth = image.Size.Width;
				float imgHeight = image.Size.Height;
	
	            var c = UIGraphics.GetCurrentContext ();
	
	            c.BeginPath ();
	            c.MoveTo (imgWidth, imgHeight/2);
	            c.AddArcToPoint (imgWidth, imgHeight, imgWidth/2, imgHeight, radius);
	            c.AddArcToPoint (0, imgHeight, 0, imgHeight/2, radius);
	            c.AddArcToPoint (0, 0, imgWidth/2, 0, radius);
	            c.AddArcToPoint (imgWidth, 0, imgWidth, imgHeight/2, radius);
	            c.ClosePath ();
	            c.Clip ();
	
	            image.Draw (new PointF (0, 0));
	            converted = UIGraphics.GetImageFromCurrentImageContext ();
	            UIGraphics.EndImageContext ();
			});
			
            return converted;
        }
开发者ID:Redth,项目名称:MonoTouch.UrlImageStore,代码行数:30,代码来源:Graphics.cs


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