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


C# UIImage.Draw方法代码示例

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


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

示例1: ViewDidLoad

		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			chart.BindingX = "Name";
			chart.Series.Add(new Series(chart, "Sales, Sales", "Sales"));
			chart.Series.Add(new Series(chart, "Expenses, Expenses", "Expenses"));
			chart.ItemsSource = SalesData.GetSalesDataList();

			chart.AxisX.Title = "Country";
			chart.AxisX.LineWidth = 2;
			chart.AxisX.MinorTickWidth = 1;
			chart.AxisX.MajorTickWidth = 0;
			chart.AxisX.IsHandleXFAxisLabelLoading = true;

			chart.AxisY.LineWidth = 2;
			chart.AxisY.MinorGridVisible = true;
			chart.AxisY.MinorGridWidth = 0.5;
			chart.AxisY.MinorGridDashes = new double[]{ 4, 4};
			chart.AxisY.MinorTickWidth = 1;
			chart.AxisY.MajorTickWidth = 2;
			chart.AxisY.MajorGridWidth = 1;
			chart.AxisY.MajorGridColor = UIColor.FromWhiteAlpha(0.8f, 1.0f);
			chart.AxisY.MajorGridFill = UIColor.FromWhiteAlpha(0.6f, 0.2f); 
			chart.AxisY.MajorUnit = 1000;
			chart.AxisY.Max = 10000;
			chart.AxisY.IsHandleXFAxisLabelLoading = true;

			chart.HandleLabelLoading += delegate (FlexChart sender, XuniRenderEngine renderEngine, int axisIndex, XuniLabelLoadingEventArgs eventArgs) 
			{
				if (axisIndex == (int)AxisType.Y)
				{
					if (eventArgs.Value <= 3000)
					{
						renderEngine.SetTextFill(UIColor.Red);
					}
					else if (eventArgs.Value <= 10000 && eventArgs.Value > 6000)
					{
						renderEngine.SetTextFill(UIColor.Green);
					}
					else 
					{
						renderEngine.SetTextFill(UIColor.Black);
					}
					eventArgs.Label = "$" + (eventArgs.Value / 1000).ToString() + "K";

					return false;
				}
				else if (axisIndex == (int)AxisType.X)
				{
					UIImage img = new UIImage("Images/" + eventArgs.Label);
					img.Draw(new CoreGraphics.CGRect(eventArgs.Region.Left, eventArgs.Region.Top, eventArgs.Region.Width, eventArgs.Region.Height));
					eventArgs.Label = "";

					return true;
				}

				return false;
			};
		}
开发者ID:GoXuni,项目名称:Xamarin.iOS-Samples,代码行数:60,代码来源:CustomizingAxesController.cs

示例2: ResizeImage

		private UIImage ResizeImage (UIImage view)
		{
			UIImage resultImage = null;

			var newSize = new CGSize (view.Size.Width / 2, view.Size.Height / 2);
			UIGraphics.BeginImageContext (newSize);
			view.Draw (new CGRect (0, 0, newSize.Width, newSize.Height));
			resultImage = UIGraphics.GetImageFromCurrentImageContext ();
			UIGraphics.EndImageContext ();

			return resultImage;
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:12,代码来源:ZoomImageView.cs

示例3: MaxResizeImage

 // resize the image to be contained within a maximum width and height, keeping aspect ratio
 public UIImage MaxResizeImage(UIImage sourceImage, float maxWidth, float maxHeight)
 {
     var sourceSize = sourceImage.Size;
     var maxResizeFactor = Math.Max(maxWidth / sourceSize.Width, maxHeight / sourceSize.Height);
     if (maxResizeFactor > 1) return sourceImage;
     var width = maxResizeFactor * sourceSize.Width;
     var height = maxResizeFactor * sourceSize.Height;
     UIGraphics.BeginImageContext(new CGSize(width, height));
     sourceImage.Draw(new CGRect(0, 0, width, height));
     var resultImage = UIGraphics.GetImageFromCurrentImageContext();
     UIGraphics.EndImageContext();
     return resultImage;
 }
开发者ID:maltegoetz,项目名称:EmotionDetector,代码行数:14,代码来源:ViewController.cs

示例4: MaxResizeImage

		public static UIImage MaxResizeImage(UIImage sourceImage, float maxWidth, float maxHeight)
		{
			var sourceSize = sourceImage.Size;
			var maxResizeFactor = Math.Max(maxWidth / sourceSize.Width, maxHeight / sourceSize.Height);
			if (maxResizeFactor > 1) return sourceImage;
			float width = (float)(maxResizeFactor * sourceSize.Width);
			float height = (float)(maxResizeFactor * sourceSize.Height);
			UIGraphics.BeginImageContext(new SizeF(width, height));
			sourceImage.Draw(new RectangleF((float)0, (float)0, width, height));
			var resultImage = UIGraphics.GetImageFromCurrentImageContext();
			UIGraphics.EndImageContext();
			return resultImage;
		}
开发者ID:kosomgua,项目名称:MapCross,代码行数:13,代码来源:ResizeImage.cs

示例5: FixOrientation

		public static UIImage FixOrientation(UIImage image)
		{
			if (image.Orientation == UIImageOrientation.Up)
			{
				return image;
			}


			UIGraphics.BeginImageContextWithOptions(image.Size, false, image.CurrentScale);
			image.Draw(new CGRect(0, 0, image.Size.Width, image.Size.Height));
			UIImage newImage = UIGraphics.GetImageFromCurrentImageContext();
			UIGraphics.EndImageContext();
			return newImage;
		}
开发者ID:natevarghese,项目名称:XamarinTen,代码行数:14,代码来源:ImageUtils.cs

示例6: InvertedImage

		private UIImage InvertedImage(UIImage originalImage)
		{
			// Invert the image by applying an affine transformation
			UIGraphics.BeginImageContext (originalImage.Size);

			// Apply an affine transformation to the original image to generate a vertically flipped image
			CGContext context = UIGraphics.GetCurrentContext ();
			var affineTransformationInvert = new CGAffineTransform(1, 0, 0, -1, 0, originalImage.Size.Height);
			context.ConcatCTM(affineTransformationInvert);
			originalImage.Draw (PointF.Empty);

			UIImage invertedImage = UIGraphics.GetImageFromCurrentImageContext ();
			UIGraphics.EndImageContext ();

			return invertedImage;
		}
开发者ID:b-theile,项目名称:monotouch-samples,代码行数:16,代码来源:ImageInverterViewController.cs

示例7: ScaledToSize

		public static UIImage ScaledToSize(UIImage image, CGSize newSize){
			CGRect scaledImageRect = new CGRect(0,0,0,0);

			nfloat aspectWidth = newSize.Width / image.Size.Width;
			nfloat aspectHeight = newSize.Height / image.Size.Height;
			nfloat aspectRatio = (nfloat)Math.Min (aspectWidth, aspectHeight);

			scaledImageRect.Size = new CGSize (image.Size.Width * aspectRatio, image.Size.Height * aspectRatio);
			scaledImageRect.X = (newSize.Width - scaledImageRect.Size.Width) / 2;
			scaledImageRect.Y = (newSize.Height - scaledImageRect.Size.Height) / 2;

			UIGraphics.BeginImageContext (newSize);
			image.Draw (scaledImageRect);
			UIImage scaledImage = UIGraphics.GetImageFromCurrentImageContext ();
			UIGraphics.EndImageContext ();
			return scaledImage;
		}
开发者ID:natevarghese,项目名称:XamarinTen,代码行数:17,代码来源:ImageUtils.cs

示例8: CreateBubbleWithBorder

		static UIImage CreateBubbleWithBorder(UIImage bubbleImg, UIColor bubbleColor, UIImage borderImg, UIColor borderColor)
		{
			bubbleImg = CreateColoredImage (bubbleColor, bubbleImg);
			borderImg = CreateColoredImage (borderColor, borderImg);

			CGSize size = bubbleImg.Size;
			UIEdgeInsets caps = CenterPointEdgeInsetsForImageSize (size);

			UIGraphics.BeginImageContextWithOptions (size, false, 0);
			var rect = new CGRect (CGPoint.Empty, size);
			bubbleImg.Draw (rect);
			borderImg.Draw (rect);

			var result = UIGraphics.GetImageFromCurrentImageContext ();
			UIGraphics.EndImageContext ();

			result = result.CreateResizableImage (caps);
			return result;
		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:19,代码来源:IncomingCell.cs

示例9: ToRounded

        public static UIImage ToRounded(UIImage source, nfloat rad)
        {
            nfloat size = (nfloat)Math.Min(source.Size.Width, source.Size.Height);

            UIGraphics.BeginImageContextWithOptions(new CGSize(size, size), false, (nfloat)0.0);

            try
            {
                CGRect bounds = new CGRect(0, 0, size, size);

                using (var path = UIBezierPath.FromRoundedRect(bounds, rad))
                {
                    path.AddClip();
                    source.Draw(bounds);
                    var newImage = UIGraphics.GetImageFromCurrentImageContext();
                    return newImage;
                }
            }
            finally
            {
                UIGraphics.EndImageContext();
            }
        }
开发者ID:piyushdutta,项目名称:FFImageLoading,代码行数:23,代码来源:RoundedTransformation.cs

示例10: Draw

        public override void Draw(CGRect rect)
        {
            // Load image
            UIImage image = new UIImage("logo.png");
            // Get drawing context
            CGContext ctx = UIGraphics.GetCurrentContext();
            // get view bounds
            CGRect bounds = this.Bounds;
            // Find the center of view
            CGPoint center = new CGPoint();
            center.X = bounds.X + bounds.Width / 2;
            center.Y = bounds.Y + bounds.Height / 2;
            // Compute the max radius of the circle
            float maxRadius = (float)Math.Sqrt(Math.Pow(bounds.Size.Width,2) + Math.Pow(bounds.Size.Height,2)) / 3.0f;

            ctx.SaveState();
            // draw outline circle with 1 pt black shadow
            ctx.AddArc(center.X, center.Y, maxRadius, 0, (float)(Math.PI * 2), true);
            CGSize offset = new CGSize(0, 1);
            CGColor shadowColor = UIColor.Black.CGColor;
            ctx.SetShadow(offset, 2, shadowColor);
            ctx.DrawPath(CGPathDrawingMode.Stroke);
            // clear shadow
            ctx.RestoreState();
            // set clipping circle
            ctx.AddArc(center.X, center.Y, maxRadius, 0, (float)(Math.PI * 2), true);
            ctx.Clip();
            // Draw the image in the circle
            image.Draw(bounds);

            CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();
            nfloat[] components = new nfloat[8]{0.8f, 0.8f, 1, 1, 0.8f, 0.8f, 1, 0};
            nfloat[] locations = new nfloat[2]{0.0f, 1};

            CGGradient gradient = new CGGradient(colorSpace, components, locations);
            ctx.DrawLinearGradient(gradient, new CGPoint(bounds.Width / 2, 0), new CGPoint(bounds.Width / 2, bounds.Height / 2), 0);
        }
开发者ID:yingfangdu,项目名称:BNR,代码行数:37,代码来源:BNRLogo.cs

示例11: FinishedLaunching

 //
 // This method is invoked when the application has loaded and is ready to run. In this 
 // method you should instantiate the window, load the UI into it and then make the window
 // visible.
 //
 // You have 17 seconds to return from this method, or iOS will terminate your application.
 //
 public override bool FinishedLaunching (UIApplication app, NSDictionary options)
 {
     window = new UIWindow (UIScreen.MainScreen.Bounds);
     
     viewController = new MergeImagesViewController ();         
     
     image1 = UIImage.FromFile ("monkey1.png");
     image2 = UIImage.FromFile ("monkey2.png");
          
     UIGraphics.BeginImageContext (UIScreen.MainScreen.Bounds.Size);
     
     image1.Draw (new CGRect (
         0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height));
     
     image2.Draw (new CGRect (
         UIScreen.MainScreen.Bounds.Width / 4, 
         UIScreen.MainScreen.Bounds.Height / 4, 
         UIScreen.MainScreen.Bounds.Width / 2, 
         UIScreen.MainScreen.Bounds.Height / 2));
     
     combinedImage = UIGraphics.GetImageFromCurrentImageContext ();
     
     UIGraphics.EndImageContext ();
     
     combinedImageView = new UIImageView (
         new CGRect (0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height));
     
     combinedImageView.Image = combinedImage;
     
     viewController.View.AddSubview (combinedImageView);
     
     window.RootViewController = viewController;
     window.MakeKeyAndVisible ();
     
     return true;
 }
开发者ID:eduardoguilarducci,项目名称:recipes,代码行数:43,代码来源:AppDelegate.cs

示例12: FixOrientation

        private static UIImage FixOrientation(UIImage image)
        {
            if (image.Orientation == UIImageOrientation.Up) return image;

            UIGraphics.BeginImageContextWithOptions(image.Size, false, image.CurrentScale);
            image.Draw(new CGRect(new CGPoint(0, 0), image.Size));
            var normalizedImage = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();
            return normalizedImage;
        }
开发者ID:jimbobbennett,项目名称:JimLib.Xamarin,代码行数:10,代码来源:ImageHelper.cs

示例13: MaxResizeImage

        // resize the image to be contained within a maximum width and height, keeping aspect ratio
        internal static UIImage MaxResizeImage(UIImage sourceImage, nfloat maxWidth, nfloat maxHeight)
        {
            if (sourceImage == null || maxWidth <= 0 || maxHeight <= 0) return null;

            var sourceSize = sourceImage.Size;
			var maxResizeFactor = (nfloat)Math.Max(maxWidth / sourceSize.Width, maxHeight / sourceSize.Height);
            if (maxResizeFactor > 1) return sourceImage;
            var width = maxResizeFactor * sourceSize.Width;
            var height = maxResizeFactor * sourceSize.Height;

            UIGraphics.BeginImageContext(new CGSize(width, height));

            sourceImage.Draw(new CGRect(0, 0, width, height));

            var resultImage = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();
            return resultImage;
        }
开发者ID:jimbobbennett,项目名称:JimLib.Xamarin,代码行数:19,代码来源:ImageHelper.cs

示例14: CreateBubbleWithBorder

        protected static UIImage CreateBubbleWithBorder(UIImage bubbleImg, UIColor bubbleColor)
        {
            bubbleImg = CreateColoredImage (bubbleColor, bubbleImg);
            CGSize size = bubbleImg.Size;

            UIGraphics.BeginImageContextWithOptions (size, false, 0);
            var rect = new CGRect (CGPoint.Empty, size);
            bubbleImg.Draw (rect);

            var result = UIGraphics.GetImageFromCurrentImageContext ();
            UIGraphics.EndImageContext ();

            return result;
        }
开发者ID:CAMongrel,项目名称:OpenFlow,代码行数:14,代码来源:BubbleCell.cs

示例15: RemoveSharpEdges

        // Child proof the image by rounding the edges of the image
        internal static UIImage RemoveSharpEdges(UIImage image)
        {
            if (image == null)
            {
                Console.WriteLine("throwing error at remove sharp edges");
                throw new ArgumentNullException ("image");
            }

            UIGraphics.BeginImageContext (new CGSize (48, 48));
            var c = UIGraphics.GetCurrentContext ();

            c.AddPath (smallPath);
            c.Clip ();

            image.Draw (new CGRect (0, 0, 48, 48));
            var converted = UIGraphics.GetImageFromCurrentImageContext ();
            UIGraphics.EndImageContext ();
            return converted;
        }
开发者ID:Clancey,项目名称:UICalendar,代码行数:20,代码来源:Graphics.cs


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