本文整理汇总了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));
}
示例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;
}
//.........这里部分代码省略.........