本文整理汇总了C#中UIImage.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# UIImage.Dispose方法的具体用法?C# UIImage.Dispose怎么用?C# UIImage.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIImage
的用法示例。
在下文中一共展示了UIImage.Dispose方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyAndDispose
public static UIImage CopyAndDispose(UIImage original)
{
UIGraphics.BeginImageContextWithOptions(original.Size, false, 0);
original.Draw(new RectangleF(0, 0, original.Size.Width, original.Size.Height));
UIImage copy = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
original.Dispose();
return copy;
}
示例2: ImageToByteArray
public static void ImageToByteArray(UIImage image, out byte[] mediaByteArray)
{
using (NSData imgData = image.AsJPEG ())
{
mediaByteArray = new byte[imgData.Length];
System.Runtime.InteropServices.Marshal.Copy (imgData.Bytes, mediaByteArray, 0, Convert.ToInt32 (imgData.Length));
}
image.Dispose ();
}
示例3: OnPhotoChosen
void OnPhotoChosen(UIImagePickerController picker, UIImage photo)
{
Photograph = PhotoManager.ScaleToSize (photo, (int) PhotoWidth, (int) PhotoHeight);
if (picker.SourceType == UIImagePickerControllerSourceType.Camera)
photo.SaveToPhotosAlbum (OnPhotoSaved);
else
photo.Dispose ();
popover.Dismiss (true);
}
示例4: OnPhotoSaved
static void OnPhotoSaved(UIImage photo, NSError error)
{
// dispose of the full-size photograph
photo.Dispose ();
}
示例5: ScaleImage
private static UIImage ScaleImage(UIImage image, int maxSize)
{
UIImage res = image;
CGImage imageRef = image.CGImage;
CGImageAlphaInfo alphaInfo = imageRef.AlphaInfo;
CGColorSpace colorSpaceInfo = CGColorSpace.CreateDeviceRGB();
if (alphaInfo == CGImageAlphaInfo.None)
{
alphaInfo = CGImageAlphaInfo.NoneSkipLast;
}
int width = imageRef.Width;
int height = imageRef.Height;
if (maxSize > 0 && maxSize < Math.Max(width, height))
{
try
{
if (height >= width)
{
width = (int) Math.Floor(width*(maxSize/(double) height));
height = maxSize;
}
else
{
height = (int) Math.Floor(height*(maxSize/(double) width));
width = maxSize;
}
int bytesPerRow = (int) image.Size.Width*4;
var buffer = new byte[(int) (bytesPerRow*image.Size.Height)];
CGBitmapContext bitmap;
if (image.Orientation == UIImageOrientation.Up || image.Orientation == UIImageOrientation.Down)
bitmap = new CGBitmapContext(buffer, width, height, imageRef.BitsPerComponent,
imageRef.BytesPerRow, colorSpaceInfo, alphaInfo);
else
bitmap = new CGBitmapContext(buffer, height, width, imageRef.BitsPerComponent,
imageRef.BytesPerRow, colorSpaceInfo, alphaInfo);
switch (image.Orientation)
{
case UIImageOrientation.Left:
bitmap.RotateCTM((float) Math.PI/2);
bitmap.TranslateCTM(0, -height);
break;
case UIImageOrientation.Right:
bitmap.RotateCTM(-((float) Math.PI/2));
bitmap.TranslateCTM(-width, 0);
break;
case UIImageOrientation.Up:
break;
case UIImageOrientation.Down:
bitmap.TranslateCTM(width, height);
bitmap.RotateCTM(-(float) Math.PI);
break;
}
bitmap.DrawImage(new RectangleF(0, 0, width, height), imageRef);
res = UIImage.FromImage(bitmap.ToImage());
}
finally
{
image.Dispose();
}
}
return res;
}
示例6: MediaChooser
void MediaChooser (object sender, UIButtonEventArgs e)
{
if (e.ButtonIndex == 1)
{
System.Console.WriteLine ("Camera");
var picker = new MediaPicker ();
// new MediaPicker (this); on Android
if (!picker.IsCameraAvailable)
{
Console.WriteLine("No camera!");
}
else
{
picker.TakePhotoAsync
(
new StoreCameraMediaOptions
{
Name = "test.jpg"
, Directory = "MediaPickerSample"
}
).ContinueWith
(
t =>
{
if (t.IsCanceled)
{
Console.WriteLine ("User canceled");
return;
}
Console.WriteLine (t.Result.Path);
imageView.Image = new UIImage(t.Result.Path);
}
, TaskScheduler.FromCurrentSynchronizationContext()
);
}
image_bytes = UIImageViewToByteArray(imageView.Image);
image.Dispose ();
}
else if (e.ButtonIndex == 2)
{
System.Console.WriteLine ("Library");
var picker = new MediaPicker ();
// new MediaPicker (this); on Android
picker.PickPhotoAsync()
.ContinueWith (t => {
if (t.IsCanceled) {
Console.WriteLine ("User canceled");
return;
}
Console.WriteLine (t.Result.Path);
imageView.Image = new UIImage(t.Result.Path);
}, TaskScheduler.FromCurrentSynchronizationContext());
}
//MOKEEEEEEEEE UIImage To ByteArray
image = imageView.Image;
image_bytes = UIImageViewToByteArray(image);
image.Dispose ();
}
开发者ID:holisticware-admin,项目名称:HolisticWare.PR.DevUG.CKVZ.SlideShow,代码行数:69,代码来源:HolisticWare.SlideShow.EXE_XIViewController.cs
示例7: FinishedLaunching
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
Otazky = db.Get();
SetRandom();
SetRootSections();
var o = new Olenenok(root);
viewController = o;
window.RootViewController = viewController;
viewController.OrientationChanged += (object sender, EventArgs e) => {
if(Current.Url != "placeholder") {
float _scale =
(UIDevice.CurrentDevice.Orientation.ToString() == UIInterfaceOrientation.LandscapeLeft.ToString() ||
UIDevice.CurrentDevice.Orientation.ToString() == UIInterfaceOrientation.LandscapeRight.ToString()) ? 1.04f : 1.6f;
var _i = UIImage.FromBundle("Images/"+ Current.Url);
var _i2 = new UIImage(_i.CGImage, _scale, UIImageOrientation.Up);
var _img = new UIImageView(_i2);
picSection.Clear();
picSection.Add(_img);
_i.Dispose(); _i2.Dispose();
//picSection.Reload(picSection, UITableViewRowAnimation.Fade);
root.Reload(picSection, UITableViewRowAnimation.Fade);
}
};
GestureFuch();
window.MakeKeyAndVisible ();
return true;
}
示例8: SetRootSections
static void SetRootSections()
{
if(root == null) {
root = new RootElement(null);
sections = new List<Section>();
}
else {
sections.ForEach(s =>
root.Remove(s, UITableViewRowAnimation.Fade));
sections = new List<Section>();
}
var queSection = new Section() { MakeElement(Current.Question, true) };
var answers = new Section();
picSection = new Section();
if(Current.Url != "placeholder") {
float scale =
(UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft ||
UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight) ? 1.04f : 1.6f;
var i = UIImage.FromBundle("Images/"+ Current.Url);
var i2 = new UIImage(i.CGImage, scale, UIImageOrientation.Up);
var img = new UIImageView(i2);
i.Dispose();
i2.Dispose();
picSection.Add(img);
root.Add(picSection);
sections.Add(picSection);
}
root.Add(queSection);
sections.Add(queSection);
var a1 = MakeElement(Current.Answer1);
var a2 = MakeElement(Current.Answer2);
var a3 = MakeElement(Current.Answer3);
answers.Add(a1);
answers.Add(a2);
if(Current.Answer3 != null) {
answers.Add(a3);
}
root.Add(answers);
sections.Add(answers);
NSAction action = () => {
if(Current.Right == 1) {
a1.Accessory = UITableViewCellAccessory.Checkmark;
a1.GetImmediateRootElement().Reload(answers, UITableViewRowAnimation.Fade);
}
if(Current.Right == 2) {
a2.Accessory = UITableViewCellAccessory.Checkmark;
a2.GetImmediateRootElement().Reload(answers, UITableViewRowAnimation.Fade);
}
if(Current.Right == 3) {
a3.Accessory = UITableViewCellAccessory.Checkmark;
a3.GetImmediateRootElement().Reload(answers, UITableViewRowAnimation.Fade);
}
};
a1.Tapped += action;
a2.Tapped += action;
a3.Tapped += action;
}