Example #1
0
		public ImageElement (UIImage image) : base ("")
		{
			if (image == null){
				Value = MakeEmpty ();
				scaled = Value;
			} else {
				Value = image;			
				scaled = Value.Scale(new SizeF(dimx, dimy));
			}
		}
Example #2
0
		public static UIImage ResizeImage (SizeF size, UIImage image, bool KeepRatio)
		{
			var curSize = image.Size;
			SizeF newSize;
			if (KeepRatio) {
				var ratio = Math.Min (size.Width / curSize.Width, size.Height / curSize.Height);
				newSize = new SizeF (curSize.Width * ratio, curSize.Height * ratio);
			
			} else {
				newSize = size;
			}
			
			return image.Scale (newSize);		
		}
			private void ShowImage(UIImage image, UIImagePickerController picker)
			{
				if (this.HasHighResScreen())
					image = image.Scale(new SizeF(new PointF(640, 640)));
				
				_controller.imageView.Image = image;
				picker.DismissModalViewControllerAnimated(true);
			}	
Example #4
0
		UIImage Scale (UIImage source)
		{
			return source.Scale(new SizeF (dimx, dimy));
		}
Example #5
0
        public static string[] SaveCutout(string name, UIImage ourpic)
        {
            if(ourpic == null)
                return new string[2]{"",""};
            Console.WriteLine ("Save");
            SizeF newSize = new SizeF (50, 50);
            UIImage thumbPic = ourpic.Scale (newSize); //measurements taken from CustomCell, alternatly 33x33
            UIImage resImage = ourpic.Scale (new SizeF (ourpic.Size.Width, ourpic.Size.Height));

            if (ourpic != null) {
                var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
                var picname = name + ".png";
                var thumbpicname = name + "_thumb.png";
                string pngfileName = System.IO.Path.Combine (documentsDirectory, picname);
                string thumbpngfileName = System.IO.Path.Combine (documentsDirectory, thumbpicname);
                NSData imgData = resImage.AsPNG ();
                NSData img2Data = thumbPic.AsPNG();

                NSError err = null;
                if (imgData.Save (pngfileName, false, out err)) {
                    Console.WriteLine ("saved as " + pngfileName);
                } else {
                    Console.WriteLine ("NOT saved as " + pngfileName + " because" + err.LocalizedDescription);
                }

                err = null;
                if (img2Data.Save (thumbpngfileName, false, out err)) {
                    Console.WriteLine ("saved as " + thumbpngfileName);
                    string[] result = new string[2] {picname,thumbpicname};
                    return result;

                } else {
                    Console.WriteLine ("NOT saved as " + thumbpngfileName + " because" + err.LocalizedDescription);
                    return null;
                }
            }
            return new string[2]{"",""};
        }
Example #6
0
		void Picked (UIImage image)
		{
			Value = image;
			scaled = image.Scale(new SizeF(dimx, dimy));

			//scaled = GraphicsUtil.PrepareForProfileView(image, dimx, dimy);
			currentController.DismissModalViewControllerAnimated (true);
			
		}
Example #7
0
        public static string[] SaveGalleryImage(string name, UIImage ourpic)
        {
            if (ourpic == null)
                return new string[2]{ "", "" };
            Console.WriteLine ("Save");
            float aspectRatio = ourpic.Size.Width / ourpic.Size.Height;
            Console.WriteLine ("ratio:" + aspectRatio);

            float sc = 200;
            if (!UserInterfaceIdiomIsPhone) {
                sc = 450;
            }
            SizeF newSize = new SizeF (sc, sc / aspectRatio);
            UIImage thumbPic = ourpic.Scale (newSize); //measurements taken from CustomCell, alternatly 33x33
            UIImage resImage = ourpic.Scale (new SizeF (ourpic.Size.Width, ourpic.Size.Height));

            if (ourpic != null) {
                var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
                var gallerydirectory = Path.Combine (documentsDirectory, "gallery");

                if (!Directory.Exists (gallerydirectory)) {
                    Directory.CreateDirectory (gallerydirectory);
                }

                var picname = name + ".png";
                var thumbpicname = name + "_thumb.png";
                string pngfileName = System.IO.Path.Combine (gallerydirectory, picname);
                string thumbpngfileName = System.IO.Path.Combine (gallerydirectory, thumbpicname);
                NSData imgData = resImage.AsPNG ();
                NSData img2Data = thumbPic.AsPNG ();

                NSError err = null;
                if (imgData.Save (pngfileName, false, out err)) {
                    Console.WriteLine ("saved as " + pngfileName);
                } else {
                    Console.WriteLine ("NOT saved as " + pngfileName + " because" + err.LocalizedDescription);
                }

                err = null;
                if (img2Data.Save (thumbpngfileName, false, out err)) {
                    Console.WriteLine ("saved as " + thumbpngfileName);
                    string[] result = new string[2] { picname, thumbpicname };
                    return result;

                } else {
                    Console.WriteLine ("NOT saved as " + thumbpngfileName + " because" + err.LocalizedDescription);
                    return null;
                }
            }
            return new string[2]{ "", "" };
        }
Example #8
0
 private void MySavePicture(UIImage image)
 {
     image = image.Scale (image.Size);
     string[] output = SaveImage (RandomGeneratedName (), image);
     RaiseSavedImageEvent (output [0], output [1]);
 }
        public void LoadImage(UIImage image)
        {
            image = image.Scale(GetScaledSize(image.Size));

            scrollView.ZoomScale = 1.0f;

            profilePicture = image;
            float zoomScale = CropHelpers.GetZoomScale(profilePicture.Size, scrollView.Frame.Size);
            var frame = new RectangleF(0f, 0f, image.Size.Width * zoomScale, image.Size.Height * zoomScale);
            var size = scrollView.Frame.Size;

            profilePictureView.Frame = frame;
            profilePictureView.Image = image;
            scrollView.ContentSize = frame.Size;
            scrollView.ContentInset = new UIEdgeInsets(size.Height * 0.8f, size.Width * 0.8f, size.Height * 0.8f, size.Width * 0.8f);
            scrollView.ContentOffset = new PointF(0, 0);
        }
Example #10
0
		public static UIImage ResizedImageIcon(UIImage image)
		{
			SizeF size = new SizeF (25.0f, 25.0f);	
			UIImage newImage = image.Scale (size, 2.0f);
			return newImage;
		}