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


C# UIImage.Scale方法代码示例

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


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

示例1: ScaledImage

 UIImage ScaledImage(UIImage image, nfloat maxWidth, nfloat maxHeight)
 {
     var maxResizeFactor = Math.Min(maxWidth / image.Size.Width, maxHeight / image.Size.Height);
     var width = maxResizeFactor * image.Size.Width;
     var height = maxResizeFactor * image.Size.Height;
     return image.Scale(new CoreGraphics.CGSize(width, height));
 }
开发者ID:MikeCodesDotNet,项目名称:Beer-Drinkin,代码行数:7,代码来源:DiscoverViewController.cs

示例2: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			Title = "Color Controls Pro";
			View.BackgroundColor = UIColor.White;

			cameraButton = UIButton.FromType (UIButtonType.RoundedRect);
			cameraButton.Frame = new CGRect(10, 60, 90,40);
			cameraButton.SetTitle ("Camera", UIControlState.Normal);
			cameraButton.TouchUpInside += (sender, e) => {
			
				TweetStation.Camera.TakePicture (this, (obj) =>{
					// https://developer.apple.com/library/ios/#documentation/uikit/reference/UIImagePickerControllerDelegate_Protocol/UIImagePickerControllerDelegate/UIImagePickerControllerDelegate.html#//apple_ref/occ/intfm/UIImagePickerControllerDelegate/imagePickerController:didFinishPickingMediaWithInfo:
					var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
					var meta = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
			
					sourceImage = photo;
					displayImage = sourceImage.Scale(new CGSize(300, 200));
					imageView.Image = displayImage;
					sourceMeta = meta;
				});
			};
			View.Add (cameraButton);

			resetButton = UIButton.FromType (UIButtonType.RoundedRect);
			resetButton.Frame = new CGRect(110, 60, 90, 40);
			resetButton.SetTitle ("Reset", UIControlState.Normal);
			resetButton.TouchUpInside += (sender, e) => {
				sliderS.Value = 1;	
				sliderB.Value = 0;
				sliderC.Value = 1;
				HandleValueChanged (sender, e);
			};
			View.Add (resetButton);

			saveButton = UIButton.FromType (UIButtonType.RoundedRect);
			saveButton.Frame = new CGRect(210, 60, 90, 40);
			saveButton.SetTitle ("Save", UIControlState.Normal);
			saveButton.TouchUpInside += (sender, e) => {
				ALAssetsLibrary library = new ALAssetsLibrary();
				
				var img = AdjustImage (sourceImage);
				
				if (sourceMeta == null) sourceMeta = new NSDictionary(); // when using 'clouds.jpg'

				library.WriteImageToSavedPhotosAlbum (img.CGImage, sourceMeta, (assetUrl, error) => {
					Console.WriteLine ("SAVED TO assetUrl:"+assetUrl);
					new UIAlertView("Saved", "Photo saved to Camera Roll", null, "OK", null).Show ();
				});
			};
			View.Add (saveButton);	

			labelC = new UILabel(new CGRect(10, 120, 90, 20));
			labelS = new UILabel(new CGRect(10, 160, 90, 20));
			labelB = new UILabel(new CGRect(10, 200, 90, 20));

			labelC.Text = "Contrast";
			labelS.Text = "Saturation";
			labelB.Text = "Brightness";

			View.Add (labelC);
			View.Add (labelS);
			View.Add (labelB);

			sliderB = new UISlider(new CGRect(100,  120, 210, 20));
			sliderS = new UISlider(new CGRect(100, 160, 210, 20));
			sliderC = new UISlider(new CGRect(100, 200, 210, 20));
			
			// http://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/filter/ci/CIColorControls
			sliderS.MinValue = 0;
			sliderS.MaxValue = 2;
			sliderS.Value = 1;
			
			sliderB.MinValue = -1;
			sliderB.MaxValue = 1;
			sliderB.Value = 0;

			sliderC.MinValue = 0;
			sliderC.MaxValue = 4;
			sliderC.Value = 1;
			
			sliderC.TouchUpInside += HandleValueChanged;
			sliderS.TouchUpInside += HandleValueChanged;
			sliderB.TouchUpInside += HandleValueChanged;
			
			View.Add (sliderC);
			View.Add (sliderS);
			View.Add (sliderB);

			imageView = new UIImageView(new CGRect(10, 240, 300, 200));
			sourceImage = UIImage.FromFile ("clouds.jpg");
			displayImage = sourceImage;
			imageView.Image = displayImage;
			View.Add (imageView);

			if (!UIImagePickerController.IsSourceTypeAvailable (UIImagePickerControllerSourceType.Camera)) {
				cameraButton.SetTitle ("No camera", UIControlState.Disabled);
				cameraButton.SetTitleColor (UIColor.Gray, UIControlState.Disabled);
				cameraButton.Enabled = false;
			}
//.........这里部分代码省略.........
开发者ID:ngoel17,项目名称:recipes,代码行数:101,代码来源:ImageViewController.cs


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