async partial void OnFilterSelectorChanged(UISegmentedControl sender) { switch (sender.SelectedSegment) { case 0: // Set up a manual image filtering chain var vignetteFilter = new GPUImageVignetteFilter(); vignetteFilter.VignetteEnd = 0.6f; vignetteFilter.VignetteStart = 0.4f; var sepiaFilter = new GPUImageSepiaFilter(); sepiaFilter.AddTarget(vignetteFilter); var imageSource = new GPUImagePicture(inputImageUrl); imageSource.AddTarget(sepiaFilter); vignetteFilter.UseNextFrameForImageCapture(); await imageSource.ProcessImageAsync(); using (var currentImage = vignetteFilter.ToImage()) using (var pngData = currentImage.AsPNG()) { pngData.Save(path1, true); } imageView.Image = UIImage.FromFile(path1); break; case 1: // Do a simpler image filtering var imageFilter = new GPUImageSketchFilter(); using (var quickFilteredImage = imageFilter.CreateFilteredImage(inputImage)) using (var pngData = quickFilteredImage.AsPNG()) { pngData.Save(path2, true); } imageView.Image = UIImage.FromFile(path2); break; } }
async partial void OnFilterSelectorChanged (UISegmentedControl sender) { switch (sender.SelectedSegment) { case 0: // Set up a manual image filtering chain var vignetteFilter = new GPUImageVignetteFilter (); vignetteFilter.VignetteEnd = 0.6f; vignetteFilter.VignetteStart = 0.4f; var sepiaFilter = new GPUImageSepiaFilter (); sepiaFilter.AddTarget (vignetteFilter); var imageSource = new GPUImagePicture (inputImageUrl); imageSource.AddTarget (sepiaFilter); vignetteFilter.UseNextFrameForImageCapture (); await imageSource.ProcessImageAsync (); using (var currentImage = vignetteFilter.ToImage ()) using (var pngData = currentImage.AsPNG ()) { pngData.Save (path1, true); } imageView.Image = UIImage.FromFile (path1); break; case 1: // Do a simpler image filtering var imageFilter = new GPUImageSketchFilter (); using (var quickFilteredImage = imageFilter.CreateFilteredImage (inputImage)) using (var pngData = quickFilteredImage.AsPNG ()) { pngData.Save (path2, true); } imageView.Image = UIImage.FromFile (path2); break; } }