Exemple #1
0
        void ApplyFilters()
        {
            float hue        = hueSlider.Value;
            float saturation = saturationSlider.Value;
            float brightness = brightnessSlider.Value;

            // Apply effects to image
            CIImage result = null;

            using (var colorControlsFilter = new CIColorControls()) {
                colorControlsFilter.Image      = baseCIImage;
                colorControlsFilter.Saturation = saturation;
                colorControlsFilter.Brightness = brightness;
                result = colorControlsFilter.OutputImage;
            }

            using (var hueAdjustFilter = new CIHueAdjust()) {
                hueAdjustFilter.Image = result;
                hueAdjustFilter.Angle = hue;
                result = hueAdjustFilter.OutputImage;
            }

            using (var context = CIContext.FromOptions(null)) {
                using (CGImage cgImage = context.CreateCGImage(result, result.Extent)) {
                    if (imageView.Image != null)
                    {
                        imageView.Image.CGImage.Dispose();
                        imageView.Image.Dispose();
                    }
                    imageView.Image = UIImage.FromImage(cgImage);
                }
            }

            result.Dispose();
        }
Exemple #2
0
        void DarkenImage()
        {
            var img       = image.Image;
            var ciImage   = new CIImage(img);
            var hueAdjust = new CIHueAdjust();   // first filter

            hueAdjust.Image = ciImage;
            hueAdjust.Angle = 2.094f;
            var sepia = new CISepiaTone();           // second filter

            sepia.Image     = hueAdjust.OutputImage; // output from last filter, input to this one
            sepia.Intensity = 0.3f;
            CIFilter color = new CIColorControls()
            { // third filter
                Saturation = 2,
                Brightness = 1,
                Contrast   = 3,
                Image      = sepia.OutputImage // output from last filter, input to this one
            };
            var output  = color.OutputImage;
            var context = CIContext.FromOptions(null);
            // ONLY when CreateCGImage is called do all the effects get rendered
            var cgimage = context.CreateCGImage(output, output.Extent);
            var ui      = UIImage.FromImage(cgimage);

            image.Image = ui;
        }
Exemple #3
0
        public CIImage HueAdjust()
        {
            var hueAdjust = new CIHueAdjust()
            {
                Image = flower,
                Angle = 1F                 // Default is 0
            };

            return(hueAdjust.OutputImage);
        }
 void DarkenImage()
 {
     var img = image.Image;
     var ciImage = new CIImage(img);
     var hueAdjust = new CIHueAdjust();   // first filter
     hueAdjust.Image = ciImage;
     hueAdjust.Angle = 2.094f;
     var sepia = new CISepiaTone();       // second filter
     sepia.Image = hueAdjust.OutputImage; // output from last filter, input to this one
     sepia.Intensity = 0.3f;
     CIFilter color = new CIColorControls()
     { // third filter
         Saturation = 2,
         Brightness = 1,
         Contrast = 3,
         Image = sepia.OutputImage    // output from last filter, input to this one
     };
     var output = color.OutputImage;
     var context = CIContext.FromOptions(null);
     // ONLY when CreateCGImage is called do all the effects get rendered
     var cgimage = context.CreateCGImage(output, output.Extent);
     var ui = UIImage.FromImage(cgimage);
     image.Image = ui;
 }
		public CIImage HueAdjust()
		{
			var hueAdjust = new CIHueAdjust()
			{
				Image = flower,
				Angle = 1F // Default is 0
			};
			
			return hueAdjust.OutputImage;
		}
        void ApplyFilters()
        {
            float hue = hueSlider.Value;
            float saturation = saturationSlider.Value;
            float brightness = brightnessSlider.Value;

            // Apply effects to image
            CIImage result = null;

            using(var colorControlsFilter = new CIColorControls ()) {
                colorControlsFilter.Image = baseCIImage;
                colorControlsFilter.Saturation = saturation;
                colorControlsFilter.Brightness = brightness;
                result = colorControlsFilter.OutputImage;
            }

            using(var hueAdjustFilter = new CIHueAdjust ()) {
                hueAdjustFilter.Image = result;
                hueAdjustFilter.Angle = hue;
                result = hueAdjustFilter.OutputImage;
            }

            using (var context = CIContext.FromOptions (null)) {
                using (CGImage cgImage = context.CreateCGImage (result, result.Extent)) {
                    if (imageView.Image != null) {
                        imageView.Image.CGImage.Dispose ();
                        imageView.Image.Dispose ();
                    }
                    imageView.Image = UIImage.FromImage (cgImage);
                }
            }

            result.Dispose ();
        }