//Filters async void ApplyFilter(FilterType filterType) { if (currentFilterType == filterType) { return; } var filterImage = Element as FilterImage; var handler = GetHandler(filterImage.OriginalSource); using (UIImage originalImage = await handler.LoadImageAsync(filterImage.OriginalSource)) { switch (filterType) { case FilterType.NoFilter: filteredImage = UIImage.FromImage(originalImage.CGImage, originalImage.CurrentScale, originalImage.Orientation); break; case FilterType.BlackAndWhite: var blackAndWhiteEffect = new CIPhotoEffectMono() { Image = new CoreImage.CIImage(originalImage) }; filteredImage = ApplyEffect(blackAndWhiteEffect, originalImage); break; case FilterType.Hifi: var hifiControls = new CIColorControls() { Image = new CoreImage.CIImage(originalImage), Brightness = .5F, // Min: 0 Max: 2 Saturation = 1.2F, // Min: -1 Max: 1 Contrast = 2.5F // Min: 0 Max: 4 }; filteredImage = ApplyEffect(hifiControls, originalImage); break; case FilterType.Vintage: var vintageEffect = new CIPhotoEffectChrome() { Image = new CoreImage.CIImage(originalImage) }; filteredImage = ApplyEffect(vintageEffect, originalImage); break; case FilterType.Saturated: var saturatedEffect = new GPUImageSaturationFilter(); saturatedEffect.Saturation = 2.5f; var imageFiltered = saturatedEffect.CreateFilteredImage(originalImage); filteredImage = imageFiltered; break; } Control.Image = filteredImage; currentFilterType = filterType; } }
protected override UIImage Transform(UIImage sourceBitmap, string path, ImageSource source, bool isPlaceholder, string key) { var effect = new CIPhotoEffectMono() { InputImage = sourceBitmap.CGImage }; var output = effect.OutputImage; var context = CIContext.FromOptions(null); CoreGraphics.CGImage cgimage = context.CreateCGImage(output, output.Extent); return(UIImage.FromImage(cgimage)); }
protected override UIImage Transform(UIImage sourceBitmap, string path, Work.ImageSource source, bool isPlaceholder, string key) { using (var effect = new CIPhotoEffectMono() { Image = sourceBitmap.CGImage }) using (var output = effect.OutputImage) using (var context = CIContext.FromOptions(null)) using (var cgimage = context.CreateCGImage(output, output.Extent)) { return(UIImage.FromImage(cgimage)); } }
protected override NSImage Transform(NSImage sourceBitmap, string path, Work.ImageSource source, bool isPlaceholder, string key) { return(Helpers.MainThreadDispatcher.PostForResult <NSImage>(() => { using (var inputImage = CIImage.FromCGImage(sourceBitmap.CGImage)) using (var filter = new CIPhotoEffectMono() { Image = inputImage }) using (var resultImage = new NSCIImageRep(filter.OutputImage)) { var nsImage = new NSImage(resultImage.Size); nsImage.AddRepresentation(resultImage); return nsImage; } })); }
/// <summary> /// Produces a low-contrast black-and-white image. /// </summary> /// <returns>The altered image.</returns> CIImage PhotoEffectMono () { var photo_effect_mono = new CIPhotoEffectMono () { Image = flower }; return photo_effect_mono.OutputImage; }