public static UIImage BuildGalleryBackground(bool landscape) { var key = "gallery_background_" + (landscape ? "landscape" : "portrait"); return(ImageCache.Get(key, () => { UIImage background0; if (Util.IsRetina() || Util.IsPad()) { background0 = UIImageEx.FromFile("Images/gallery/background_seamless_high.png"); } else { background0 = UIImageEx.FromFile("Images/gallery/background_seamless_low.png"); } // Snip the background height so we don't shrink the viewable area var delta = background0.Size.Height - (Util.IsPortrait() ? GalleryScreenHeight : GalleryScreenWidth); // - 20; var frame = new RectangleF(0, delta, background0.Size.Width, background0.Size.Height - delta); var background1 = ImageHelper.Crop(background0, frame); background0.Dispose(); return background1; })); }
public override void ViewDidLoad() { base.ViewDidLoad(); AppDelegate.NavigationBar.SetBackButtonOn(this); SetBackgroundView(Util.IsLandscape()); if (_view != null) { _view.Dispose(); _view = null; } // Set up our custom ScrollView _view = new PieceFullView(View.Bounds); _view.BackgroundColor = UIColor.Clear; _view.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _view.ShowsVerticalScrollIndicator = false; _view.ShowsHorizontalScrollIndicator = false; _view.BouncesZoom = true; _view.Delegate = new ScrollViewDelegate(); // Added by me (snap back does not occur on device) _view.UserInteractionEnabled = true; _view.MultipleTouchEnabled = true; _view.ScrollsToTop = false; _view.PagingEnabled = false; View.AddSubview(_view); // Set up the ImageView that's going inside our scroll view UIImage image = UIImageEx.FromFile(_piece.Source); UIImageView iv = new UIImageView(image); image.Dispose(); iv.Layer.ShadowPath = UIBezierPath.FromRect(iv.Bounds).CGPath; iv.Layer.ShouldRasterize = true; iv.Layer.MasksToBounds = false; iv.Layer.ShadowColor = UIColor.Black.CGColor; iv.Layer.ShadowOpacity = 1.0f; iv.Layer.ShadowRadius = 10.0f; iv.Layer.ShadowOffset = new SizeF(0f, 1f); // Finish the ScrollView setup _view.ContentSize = iv.Frame.Size; _view.SetChildView(iv); _view.MaximumZoomScale = 2.0f; SetMinimumZoomForCurrentFrame(); _view.SetZoomScale(_view.MinimumZoomScale, false); }
public static UIImage GeneratePieceThumbnail(string source, float w, float h, bool rounded, bool notDetailView) { // If we're using the retina display, we need to double the resolution, // even though when saving the image we still use 32x as the basis var sw = w; var sh = h; if (DimensionSet.IsRetinaDisplay) { sw *= 2f; sh *= 2f; } // On the iPad, the thumbnail is rendered too large as-is if (DimensionSet.Idiom == UIUserInterfaceIdiom.Pad && notDetailView) { sw *= 2f; sh *= 2f; w /= 2.5f; h /= 2.5f; } var image = UIImageEx.FromFile(source); // Don't EVER bundle cache the source file!! var small = ImageHelper.CropResize(image, sw, sh, CropPosition.Center); image.Dispose(); UIImage thumb; if (rounded) { var roundThumb = ImageHelper.MakeRoundCornerImage(small, 5, 5); thumb = ImageHelper.ImageToFitSize(roundThumb, new SizeF(w, h)); roundThumb.Dispose(); } else { thumb = ImageHelper.ImageToFitSize(small, new SizeF(w, h)); } small.Dispose(); return(thumb); }
public static UIImage Get(string key) { if (!_images.ContainsKey(key)) { var path = Path.Combine(_path, key); UIImage image; if (File.Exists(path)) { image = UIImageEx.FromFile(path); } else { return(null); } return(image); } return(_images[key]); }
public static UIImage Get(string key, Func <UIImage> generate) { if (!_images.ContainsKey(key)) { var path = Path.Combine(_path, key); UIImage image; if (File.Exists(path)) { image = UIImageEx.FromFile(path); } else { image = generate(); Save(path, image); } return(image); } return(_images[key]); }
public static UIImage GenerateGalleryPiece(Piece piece, float width, float height) { if (Util.IsPad()) { if (Util.IsLandscape()) { // iPad Landscape width = 720; height = 515; } else { // iPad Portrait width = 440; height = 605; } } else { if (Util.IsLandscape()) { // iPhone Landscape width = 300; height = 190; } else { // iPhone Portrait width = 200; height = 275; } } var image = UIImageEx.FromFile(piece.Source); var final = ImageHelper.ImageToFitSize(image, new SizeF(width, height)); image.Dispose(); return(final); }