public static CGImagePropertyOrientation ToCGImagePropertyOrientation(this UIImageOrientation self) { // Take action based on value switch (self) { case UIImageOrientation.Up: return(CGImagePropertyOrientation.Up); case UIImageOrientation.UpMirrored: return(CGImagePropertyOrientation.UpMirrored); case UIImageOrientation.Down: return(CGImagePropertyOrientation.Down); case UIImageOrientation.DownMirrored: return(CGImagePropertyOrientation.DownMirrored); case UIImageOrientation.Left: return(CGImagePropertyOrientation.Left); case UIImageOrientation.LeftMirrored: return(CGImagePropertyOrientation.LeftMirrored); case UIImageOrientation.Right: return(CGImagePropertyOrientation.Right); case UIImageOrientation.RightMirrored: return(CGImagePropertyOrientation.RightMirrored); } // Default to up return(CGImagePropertyOrientation.Up); }
/// <summary> /// To the CG image orientation. /// </summary> /// <returns>The CG image orientation.</returns> /// <param name="value">Value.</param> public static CGImageOrientation ToCGImageOrientation(this UIImageOrientation value) { switch (value) { case UIImageOrientation.Up: return(CGImageOrientation.Default); case UIImageOrientation.Down: return(CGImageOrientation.UpsideDown); case UIImageOrientation.Left: return(CGImageOrientation.RotatedRight); case UIImageOrientation.Right: return(CGImageOrientation.RotatedLeft); case UIImageOrientation.UpMirrored: return(CGImageOrientation.Mirrored); case UIImageOrientation.DownMirrored: return(CGImageOrientation.UpsideDownMirrored); case UIImageOrientation.LeftMirrored: return(CGImageOrientation.RotatedRightMirrored); case UIImageOrientation.RightMirrored: return(CGImageOrientation.RotatedLeftMirrored); default: return(CGImageOrientation.Default); } }
public static FileStream ResizeImageIOS(Stream imageData, float width, float height) { UIImage originalImage = ImageFromByteArray(imageData); UIImageOrientation orientation = originalImage.Orientation; //create a 24bit RGB image using (CGBitmapContext context = new CGBitmapContext(IntPtr.Zero, (int)width, (int)height, 8, 4 * (int)width, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { RectangleF imageRect = new RectangleF(0, 0, width, height); // draw the image context.DrawImage(imageRect, originalImage.CGImage); UIKit.UIImage resizedImage = UIKit.UIImage.FromImage(context.ToImage(), 0, orientation); string path = Path.Combine(Kit.Tools.Instance.TemporalPath, $"{Guid.NewGuid():N}.jpeg"); using (FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { using (MemoryStream memoryStream = new MemoryStream(resizedImage.AsJPEG().ToArray())) { memoryStream.Position = 0; memoryStream.CopyTo(fileStream); return(fileStream); } } // save the image as a jpeg } }
public ColorThiefBitmap(UIImage uiImage) { image = uiImage; orientation = image.Orientation; Width = (int)image.CGImage.Width; Height = (int)image.CGImage.Height; }
void SelectedAssets(List <ALAsset> assets) { var results = new List <AssetResult>(assets.Count); foreach (var asset in assets) { var obj = asset.AssetType; if (obj == default(ALAssetType)) { continue; } var rep = asset.DefaultRepresentation; if (rep != null) { var result = new AssetResult(); UIImageOrientation orientation = UIImageOrientation.Up; var cgImage = rep.GetFullScreenImage(); //set if not null if (cgImage != null) { result.Image = new UIImage(cgImage, 1.0f, orientation); } result.Name = rep.Filename; result.Path = rep.Url.AbsoluteString; results.Add(result); } } _TaskCompletionSource.TrySetResult(results); }
public byte[] ResizeImage(byte[] imageData) { UIImage originalImage = ImageFromByteArray(imageData); UIImageOrientation orientation = originalImage.Orientation; int width = (int)originalImage.Size.Width; int height = (int)originalImage.Size.Height; //create a 24bit RGB image using (CGBitmapContext context = new CGBitmapContext(IntPtr.Zero, (int)width, (int)height, 8, (int)(4 * width), CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { RectangleF imageRect = new RectangleF(0, 0, width, height); // draw the image context.DrawImage(imageRect, originalImage.CGImage); UIKit.UIImage resizedImage = UIKit.UIImage.FromImage(context.ToImage(), 0, orientation); // save the image as a jpeg return(resizedImage.AsJPEG().ToArray()); } }
public static UIImage RotateImageByOrientation(this UIImage image, UIImageOrientation orientation) { using (CGImage imgRef = image.CGImage) { UIImage imgCopy = image; CGAffineTransform transform = CGAffineTransform.MakeIdentity(); switch (orientation) { case UIImageOrientation.Up: imgCopy = image; break; case UIImageOrientation.Down: imgCopy = UIImage.FromImage(imgRef, image.CurrentScale, UIImageOrientation.Down); break; case UIImageOrientation.Right: imgCopy = UIImage.FromImage(imgRef, image.CurrentScale, UIImageOrientation.Right); break; case UIImageOrientation.Left: imgCopy = UIImage.FromImage(imgRef, image.CurrentScale, UIImageOrientation.Left); break; default: break; } return(imgCopy); } }
public void SaveOrientation() { switch (orientation) { case UIImageOrientation.Up: orientation = UIImageOrientation.Right; break; case UIImageOrientation.Right: orientation = UIImageOrientation.Down; break; case UIImageOrientation.Down: orientation = UIImageOrientation.Left; break; case UIImageOrientation.Left: orientation = UIImageOrientation.Up; break; default: orientation = UIImageOrientation.Up; break; } }
// Returns the EXIF/TIFF orientation value corresponding to the given UIImageOrientation value. CIImageOrientation Convert(UIImageOrientation imageOrientation) { switch (imageOrientation) { case UIImageOrientation.Up: return(CIImageOrientation.TopLeft); case UIImageOrientation.Down: return(CIImageOrientation.BottomRight); case UIImageOrientation.Left: return(CIImageOrientation.LeftBottom); case UIImageOrientation.Right: return(CIImageOrientation.RightTop); case UIImageOrientation.UpMirrored: return(CIImageOrientation.TopRight); case UIImageOrientation.DownMirrored: return(CIImageOrientation.BottomLeft); case UIImageOrientation.LeftMirrored: return(CIImageOrientation.LeftTop); case UIImageOrientation.RightMirrored: return(CIImageOrientation.RightBottom); default: throw new NotImplementedException(); } }
public byte[] ResizeImage(byte[] imageData, float widthScale, float heightScale) { UIImage originalImage = ImageFromByteArray(imageData); UIImageOrientation orientation = originalImage.Orientation; var width = (int)(originalImage.Size.Width * widthScale); var height = (int)(originalImage.Size.Height * heightScale); //create a 24bit RGB image using (CGBitmapContext context = new CGBitmapContext(IntPtr.Zero, (int)width, (int)height, 8, 4 * (int)width, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { RectangleF imageRect = new RectangleF(0, 0, width, height); // draw the image context.DrawImage(imageRect, originalImage.CGImage); UIKit.UIImage resizedImage = UIKit.UIImage.FromImage(context.ToImage(), 0, orientation); // pngとしたときのバイト配列を返す return(resizedImage.AsPNG().ToArray()); } }
public async Task <byte[]> ResizeImageAsync(byte[] imageData, float width, float height) { await Task.Run(() => { UIImage originalImage = ImageFromByteArray(imageData); UIImageOrientation orientation = originalImage.Orientation; //create a 24bit RGB image using (CGBitmapContext context = new CGBitmapContext(IntPtr.Zero, (int)width, (int)height, 8, 4 * (int)width, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { RectangleF imageRect = new RectangleF(0, 0, width, height); // draw the image context.DrawImage(imageRect, originalImage.CGImage); resizedImage = UIKit.UIImage.FromImage(context.ToImage(), 0, orientation); } }); // save the image as a jpeg return(resizedImage.AsPNG().ToArray()); }
public static CIImageOrientation ToCIImageOrientation(this UIImageOrientation self) { // Take action based on value switch (self) { case UIImageOrientation.Up: return(CIImageOrientation.TopLeft); case UIImageOrientation.UpMirrored: return(CIImageOrientation.TopRight); case UIImageOrientation.Down: return(CIImageOrientation.BottomLeft); case UIImageOrientation.DownMirrored: return(CIImageOrientation.BottomRight); case UIImageOrientation.Left: return(CIImageOrientation.LeftTop); case UIImageOrientation.LeftMirrored: return(CIImageOrientation.LeftBottom); case UIImageOrientation.Right: return(CIImageOrientation.RightTop); case UIImageOrientation.RightMirrored: return(CIImageOrientation.RightBottom); } // Default to up return(CIImageOrientation.TopLeft); }
private UIImage RotateImage(UIImage src, UIImageOrientation orientation) { UIGraphics.BeginImageContext(src.Size); if (orientation == UIImageOrientation.Right) { CGAffineTransform.MakeRotation((nfloat)radians(90)); } else if (orientation == UIImageOrientation.Left) { CGAffineTransform.MakeRotation((nfloat)radians(-90)); } else if (orientation == UIImageOrientation.Down) { } else if (orientation == UIImageOrientation.Up) { CGAffineTransform.MakeRotation((nfloat)radians(90)); } src.Draw(new CGPoint(0, 0)); UIImage image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); return(image); }
static Size ApplyOrientation (Size size, UIImageOrientation orientation) { if (!NeedsRotate (orientation)) return size; return new Size (size.Height, size.Width); }
public void LoadImage(UIImage uiImage) { image = uiImage; orientation = image.Orientation; width = (int)image.CGImage.Width; height = (int)image.CGImage.Height; }
public Task <byte[]> ResizeImageToHalfSizeAsync(byte[] imageData) { UIImage originalImage = ImageFromByteArray(imageData); int halfImageHeight = (int)originalImage.Size.Height / 2; int halfImageWidth = (int)originalImage.Size.Width / 2; UIImageOrientation orientation = originalImage.Orientation; // create a 24bit RGB image using (CGBitmapContext context = new CGBitmapContext( IntPtr.Zero, halfImageWidth, halfImageHeight, 8, 4 * halfImageWidth, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { RectangleF imageRect = new RectangleF(0, 0, halfImageWidth, halfImageHeight); // draw the image context.DrawImage(imageRect, originalImage.CGImage); UIImage resizedImage = UIImage.FromImage(context.ToImage(), 0, orientation); // save the image as a jpeg return(Task.FromResult(resizedImage.AsJPEG().ToArray())); } }
public static UIImage CroppedToSize(this UIImage image, CGSize imageSize, CGPoint offset, bool mirror) { UIGraphics.BeginImageContextWithOptions(imageSize, true, 0f); image.Draw(offset); UIImage result = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); if (mirror) { UIImageOrientation imageOrientation = UIImageOrientation.Up; switch (result.Orientation) { case UIImageOrientation.Down: imageOrientation = UIImageOrientation.DownMirrored; break; case UIImageOrientation.DownMirrored: imageOrientation = UIImageOrientation.Down; break; case UIImageOrientation.Left: imageOrientation = UIImageOrientation.LeftMirrored; break; case UIImageOrientation.LeftMirrored: imageOrientation = UIImageOrientation.Left; break; case UIImageOrientation.Right: imageOrientation = UIImageOrientation.RightMirrored; break; case UIImageOrientation.RightMirrored: imageOrientation = UIImageOrientation.Right; break; case UIImageOrientation.Up: imageOrientation = UIImageOrientation.UpMirrored; break; case UIImageOrientation.UpMirrored: imageOrientation = UIImageOrientation.Up; break; default: break; } result = new UIImage(result.CGImage, result.CurrentScale, imageOrientation); } return(result); }
public byte[] ResizeTheImage(byte[] imageData, float width, float height) { UIImage originalImage = ImageFromByteArray(imageData); originalImage = MaxResizeImage(originalImage, width, height); UIImageOrientation orientation = originalImage.Orientation; return(originalImage.AsJPEG().ToArray()); }
private RectangleF CalculateBoundsForScaling( float originalWidth, float originalHeight, UIImageOrientation originalImageOrientation, int resolution, ScaleMode scaleMode) { float width; float height; if (originalImageOrientation == UIImageOrientation.Up) { width = originalWidth; height = originalHeight; } else if (originalImageOrientation == UIImageOrientation.Right) { width = originalHeight; height = originalWidth; } else { throw new ArgumentException("Unsupported image orientation (" + originalImageOrientation + ")."); } float ratio = width / height; SizeF scaledSize = new SizeF(); if ((ratio > 1 && scaleMode == ScaleMode.Fit) || (ratio < 1 && scaleMode == ScaleMode.Fill)) { scaledSize.Width = resolution; scaledSize.Height = resolution / ratio; } else { scaledSize.Width = resolution * ratio; scaledSize.Height = resolution; } PointF point = PointF.Empty; if (scaleMode == ScaleMode.Fill) { if (scaledSize.Height > scaledSize.Width) { point = new PointF(0, (resolution - scaledSize.Height) * 0.5f); } else if (scaledSize.Height < scaledSize.Width) { point = new PointF((resolution - scaledSize.Width) * 0.5f, 0); } } return(new RectangleF(point, scaledSize)); }
public byte[] ResizeImage(byte[] imageData, float width, float height) { UIImage originalImage = ImageFromByteArray(imageData); UIImageOrientation orientImg = originalImage.Orientation; float oldWidth = (float)originalImage.Size.Width; float oldHeight = (float)originalImage.Size.Height; float scaleFactor = 0f; if (oldWidth > oldHeight) { scaleFactor = width / oldWidth; } else { scaleFactor = height / oldHeight; } float newHeight = oldHeight * scaleFactor; float newWidth = oldWidth * scaleFactor; //create a 24bit RGB image using (CGBitmapContext context = new CGBitmapContext(IntPtr.Zero, (int)newWidth, (int)newHeight, 8, (int)(4 * newWidth), CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { RectangleF imageRect = new RectangleF(0, 0, newWidth, newHeight); // draw the image context.DrawImage(imageRect, originalImage.CGImage); //UIKit.UIImage resizedImage = UIKit.UIImage.FromImage(context.ToImage()); //Das skalierte Bild um 90 Grad drehen //UIKit.UIImage resizedImage = UIKit.UIImage.FromImage(context.ToImage(), 1, UIImageOrientation.Right); UIKit.UIImage resizedImage = UIKit.UIImage.FromImage(context.ToImage(), 1, orientImg); //Das gedrehte Bild neu rendern, höhe und Breite vertauscht um das Seitenverhältniss beizubehalten UIGraphics.BeginImageContextWithOptions(new CGSize((float)resizedImage.CGImage.Height, (float)resizedImage.CGImage.Width), true, 1.0f); //TODO: Height und Width sind evtl. vertauscht resizedImage.Draw(new CGRect(0, 0, (float)resizedImage.CGImage.Height, (float)resizedImage.CGImage.Width)); //TODO: Height und Width sind evtl. vertauscht var resultImage = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); resizedImage = resultImage; return(resizedImage.AsJPEG(100).ToArray()); // save the image as a jpeg //return resizedImage.AsJPEG(100).ToArray(); } }
private void RotateImage(UIImageOrientation orientation) { var rotated = new UIImage(photoView.Image.CGImage, photoView.Image.CurrentScale, orientation); UIGraphics.BeginImageContextWithOptions(rotated.Size, false, rotated.CurrentScale); var drawRect = new CGRect(0, 0, rotated.Size.Width, rotated.Size.Height); rotated.Draw(drawRect); ImageAsset = photoView.Image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); }
public UIImage ImageWithOrientation (UIImageOrientation orientation) { float scale = UIScreen.MainScreen.Scale; UIImage image = null; using (CGImage cgImage = renderContext.ToImage ()) { image = UIImage.FromImage (cgImage, scale, orientation); } return image; }
public UIImage ImageWithOrientation(UIImageOrientation orientation) { float scale = UIScreen.MainScreen.Scale; UIImage image = null; using (CGImage cgImage = renderContext.ToImage()) { image = UIImage.FromImage(cgImage, scale, orientation); } return(image); }
static bool NeedsRotate (UIImageOrientation orientation) { switch (orientation) { case UIImageOrientation.Left: case UIImageOrientation.Right: case UIImageOrientation.LeftMirrored: case UIImageOrientation.RightMirrored: return true; default: return false; } }
/// <summary> /// Rotates the image. /// </summary> /// <param name="image">Image.</param> private void RotateImage(ref UIImage image) { CGImage imgRef = image.CGImage; CGAffineTransform transform = CGAffineTransform.MakeIdentity(); var imgHeight = imgRef.Height * _imgScale; var imgWidth = imgRef.Width * _imgScale; CGRect bounds = new CGRect(0, 0, imgWidth, imgHeight); CGSize imageSize = new CGSize(imgWidth, imgHeight); UIImageOrientation orient = image.Orientation; switch (orient) { case UIImageOrientation.Up: transform = CGAffineTransform.MakeIdentity(); break; case UIImageOrientation.Down: transform = CGAffineTransform.MakeTranslation(imageSize.Width, imageSize.Height); transform = CGAffineTransform.Rotate(transform, (float)Math.PI); break; case UIImageOrientation.Right: bounds.Size = new CGSize(bounds.Size.Height, bounds.Size.Width); transform = CGAffineTransform.MakeTranslation(imageSize.Height, 0); transform = CGAffineTransform.Rotate(transform, (float)Math.PI / 2.0f); break; default: throw new Exception("Invalid image orientation"); } UIGraphics.BeginImageContext(bounds.Size); CGContext context = UIGraphics.GetCurrentContext(); if (orient == UIImageOrientation.Right) { context.ScaleCTM(-1, 1); context.TranslateCTM(-imgHeight, 0); } else { context.ScaleCTM(1, -1); context.TranslateCTM(0, -imgHeight); } context.ConcatCTM(transform); context.DrawImage(new CGRect(0, 0, imgWidth, imgHeight), imgRef); image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); }
public static UIImage RotateImage(UIImage image, UIImageOrientation orientation) { var rotated = new UIImage(image.CGImage, image.CurrentScale, orientation); UIGraphics.BeginImageContextWithOptions(rotated.Size, false, rotated.CurrentScale); var drawRect = new CGRect(0, 0, rotated.Size.Width, rotated.Size.Height); rotated.Draw(drawRect); image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); return(image); }
static UIImage Resize(CGImage original, nfloat scale, UIImageOrientation orientation, CGSize newSize) { UIGraphics.BeginImageContext(newSize); var rect = new CGRect(CGPoint.Empty, newSize); UIImage.FromImage(original, scale, orientation).Draw(rect); UIImage resized = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); return(resized); }
public void UpdateCell(AssetImage image, bool isSelected) { MainImageView.Layer.MasksToBounds = true; Image = image; UIImageOrientation orientation = UIImageOrientation.Up; MainImageView.Image = new UIImage(Image.Thumbnail, 0.8f, orientation); SelectedIconBackgroundView.Layer.CornerRadius = SelectedIconBackgroundView.Frame.Width / 2; UpdateSelectedState(isSelected, false); CreateGradientIfNeeded(); }
public static byte[] ResizeImageIOS(UIImage originalImage, float width, float height) { UIImageOrientation orientation = originalImage.Orientation; using (CGBitmapContext context = new CGBitmapContext(IntPtr.Zero, (int)width, (int)height, 8, 4 * (int)width, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { //RectangleF imageRect = new RectangleF(0, 0, width, height); //context.DrawImage(imageRect, originalImage.CGImage); UIKit.UIImage resizedImage = UIKit.UIImage.FromImage(context.ToImage(), 0, orientation); return(resizedImage.AsJPEG().ToArray()); } }
public static UIImage Rotate(UIImage src, UIImageOrientation orientation) { if (orientation == UIImageOrientation.Up || orientation == UIImageOrientation.UpMirrored) { return(src); } nfloat angle = 0; if (orientation == UIImageOrientation.Right || orientation == UIImageOrientation.RightMirrored) { angle = 90; } if (orientation == UIImageOrientation.Down || orientation == UIImageOrientation.DownMirrored) { angle = 180; } if (orientation == UIImageOrientation.Left || orientation == UIImageOrientation.LeftMirrored) { angle = 270; } var radians = GetRadians(angle); CGAffineTransform t = CGAffineTransform.MakeRotation(radians); UIView rotatedViewBox = new UIView(new CGRect(0, 0, src.Size.Width, src.Size.Height)); rotatedViewBox.Transform = t; CGSize rotatedSize = rotatedViewBox.Frame.Size; UIGraphics.BeginImageContext(src.Size); var context = UIGraphics.GetCurrentContext(); context.TranslateCTM(src.Size.Width / 2.0f, src.Size.Height / 2.0f); context.RotateCTM(radians); context.ScaleCTM(1.0f, -1.0f); context.TranslateCTM(-rotatedSize.Width / 2.0f, -rotatedSize.Height / 2.0f); context.DrawImage(new CGRect(0, 0, rotatedSize.Width, rotatedSize.Height), src.CGImage); UIImage image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); return(image); }
public byte[] CompressImage(byte[] imageData, float width, float height) { UIImage sourceImage = ConvertImage(imageData); UIImageOrientation orientation = sourceImage.Orientation; using (CGBitmapContext cGBitmapContext = new CGBitmapContext(IntPtr.Zero, (int)width, (int)height, 8, 4 * (int)width, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { RectangleF imageReact = new RectangleF(0, 0, width, height); cGBitmapContext.DrawImage(imageReact, sourceImage.CGImage); UIKit.UIImage resizedImage = UIKit.UIImage.FromImage(cGBitmapContext.ToImage(), 0, orientation); return(resizedImage.AsJPEG().ToArray()); } }
public void Resize(float width, float height) { UIImage originalImage = this.Image; UIImageOrientation orientation = originalImage.Orientation; //create a 24bit RGB image using (CGBitmapContext context = new CGBitmapContext(IntPtr.Zero, (int)width, (int)height, 8, (int)(4 * width), CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { CGRect imageRect = new CGRect(0, 0, width, height); // draw the image context.DrawImage(imageRect, originalImage.CGImage); this.Image = UIKit.UIImage.FromImage(context.ToImage(), 0, orientation); } }
public byte[] ResizeImage(byte[] ImageData, float fWidth, float fHeight) { UIImage originalImage = ImageFromByteArray(ImageData); UIImageOrientation orientation = originalImage.Orientation; using (CGBitmapContext context = new CGBitmapContext(IntPtr.Zero, (int)fWidth, (int)fHeight, 8, (int)(4 * fWidth), CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst)) { CGRect imageRect = new CGRect(0, 0, fWidth, fHeight); // draw the image context.DrawImage(imageRect, originalImage.CGImage); UIKit.UIImage resizedImage = UIKit.UIImage.FromImage(context.ToImage(), 0, orientation); // save the image as a jpeg return(resizedImage.AsJPEG().ToArray()); } }
public static int ToExifOrientation (UIImageOrientation o) { switch (o) { default: case UIImageOrientation.Up: return 1; case UIImageOrientation.Down: return 3; case UIImageOrientation.Left: return 8; case UIImageOrientation.Right: return 6; case UIImageOrientation.UpMirrored: return 2; case UIImageOrientation.DownMirrored: return 4; case UIImageOrientation.LeftMirrored: return 5; case UIImageOrientation.RightMirrored: return 7; } }
// Returns the EXIF/TIFF orientation value corresponding to the given UIImageOrientation value. CIImageOrientation Convert(UIImageOrientation imageOrientation) { switch (imageOrientation) { case UIImageOrientation.Up: return CIImageOrientation.TopLeft; case UIImageOrientation.Down: return CIImageOrientation.BottomRight; case UIImageOrientation.Left: return CIImageOrientation.LeftBottom; case UIImageOrientation.Right: return CIImageOrientation.RightTop; case UIImageOrientation.UpMirrored: return CIImageOrientation.TopRight; case UIImageOrientation.DownMirrored: return CIImageOrientation.BottomLeft; case UIImageOrientation.LeftMirrored: return CIImageOrientation.LeftTop; case UIImageOrientation.RightMirrored: return CIImageOrientation.RightBottom; default: throw new NotImplementedException (); } }
/// <summary> /// Detects the in image. /// </summary> /// <returns>The in image.</returns> /// <param name="image">Image.</param> /// <param name="imageOrientation">Image orientation.</param> public Face[] DetectInImage(Texture2D image, UIImageOrientation imageOrientation) { return DetectInImage(image, imageOrientation.ToCGImageOrientation()); }
static UIImage Resize(CGImage original, nfloat scale, UIImageOrientation orientation, CGSize newSize) { UIGraphics.BeginImageContext(newSize); var rect = new CGRect (CGPoint.Empty, newSize); UIImage.FromImage (original, scale, orientation).Draw (rect); UIImage resized = UIGraphics.GetImageFromCurrentImageContext (); UIGraphics.EndImageContext (); return resized; }