當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。