Tinting a grayscale NSImage (or CIImage)

The above solution didn’t work for me. But this much easier solution works great for me – (NSImage *)imageTintedWithColor:(NSColor *)tint { NSImage *image = [self copy]; if (tint) { [image lockFocus]; [tint set]; NSRect imageRect = {NSZeroPoint, [image size]}; NSRectFillUsingOperation(imageRect, NSCompositeSourceIn); [image unlockFocus]; } return image; }

What is the best Core Image filter to produce black and white effects?

– (UIImage *)imageBlackAndWhite { CIImage *beginImage = [CIImage imageWithCGImage:self.CGImage]; CIImage *blackAndWhite = [CIFilter filterWithName:@”CIColorControls” keysAndValues:kCIInputImageKey, beginImage, @”inputBrightness”, [NSNumber numberWithFloat:0.0], @”inputContrast”, [NSNumber numberWithFloat:1.1], @”inputSaturation”, [NSNumber numberWithFloat:0.0], nil].outputImage; CIImage *output = [CIFilter filterWithName:@”CIExposureAdjust” keysAndValues:kCIInputImageKey, blackAndWhite, @”inputEV”, [NSNumber numberWithFloat:0.7], nil].outputImage; CIContext *context = [CIContext contextWithOptions:nil]; CGImageRef cgiimage = [context createCGImage:output fromRect:output.extent]; //UIImage *newImage = [UIImage imageWithCGImage:cgiimage]; UIImage *newImage … Read more

Correct crop of CIGaussianBlur

Take the following code as an example… CIContext *context = [CIContext contextWithOptions:nil]; CIImage *inputImage = [[CIImage alloc] initWithImage:image]; CIFilter *filter = [CIFilter filterWithName:@”CIGaussianBlur”]; [filter setValue:inputImage forKey:kCIInputImageKey]; [filter setValue:[NSNumber numberWithFloat:5.0f] forKey:@”inputRadius”]; CIImage *result = [filter valueForKey:kCIOutputImageKey]; CGImageRef cgImage = [context createCGImage:result fromRect:[result extent]]; This results in the images you provided above. But if I instead use … Read more

Are the Core Image filters in iOS 5.0 fast enough for realtime video processing?

Now that Core Image has been out on iOS for a while, we can talk about some hard performance numbers. I created a benchmark application as part of the testing for my GPUImage framework, and profiled the performance of raw CPU-based filters, Core Image filters, and GPUImage filters with live video feeds. The following were … Read more

How can I generate a barcode from a string in Swift?

You could use a CoreImage (import CoreImage) filter to do that! class Barcode { class func fromString(string : String) -> UIImage? { let data = string.data(using: .ascii) if let filter = CIFilter(name: “CICode128BarcodeGenerator”) { filter.setValue(data, forKey: “inputMessage”) if let outputCIImage = filter.outputImage { return UIImage(ciImage: outputCIImage) } } return nil } } let img = … Read more

How to Convert UIImage to CIImage and vice versa

CIImage *ciImage = [UIImage imageNamed:@”test.png”].CIImage; UIImage *uiImage = [[UIImage alloc] initWithCIImage:ciImage]; To fix the case where myUIImage.CIImage returns nil like [UIImageView image], you can instead do [CIImage imageWithCGImage:myUIImage.CGImage] – Dylan Hand Swift version: let ciImage = UIImage(named: “test.png”)!.ciImage let uiImage = UIImage(ciImage: ciImage) To fix the case where myUIImage.ciImage returns nil like you can instead … Read more

Creating a blurring overlay view

You can use UIVisualEffectView to achieve this effect. This is a native API that has been fine-tuned for performance and great battery life, plus it’s easy to implement. Swift: //only apply the blur if the user hasn’t disabled transparency effects if !UIAccessibility.isReduceTransparencyEnabled { view.backgroundColor = .clear let blurEffect = UIBlurEffect(style: .dark) let blurEffectView = UIVisualEffectView(effect: … Read more

bahis casinocanlı casino siteleritürkçe altyazılı pornocanlı bahis casino