I'm working on a video conferencing app, and the following code draws a frame to the screen succesfully:
-(int)drawFrameOnMainThread{
if(mBitmapContext){
if(mDisplay){
CGImageRef imageRef = CGBitmapContextCreateImage(mBitmapContext);
#if TARGET_OS_IPHONE
UIImage *image = [UIImage imageWithCGImage:imageRef];
[self performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:YES];
#elif TARGET_OS_MAC
[mDisplay setCurrentImage:imageRef];
#endif
CGImageRelease(imageRef);
}
}
return 0;
}
I want to apply a CIFilter to the frame being drawn, so I modify the iOS section of the code like so:
UIImage *image = [UIImage imageWithCGImage:imageRef];
CIImage *beginImage = image.CIImage;
CIContext *context = [CIContext contextWithOptions:nil];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"
keysAndValues: kCIInputImageKey, beginImage,
@"inputIntensity", [NSNumber numberWithFloat:0.8], nil];
CIImage *outputImage = [filter outputImage];
CGImageRef cgimg =
[context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newImg = [UIImage imageWithCGImage:cgimg];
[self performSelectorOnMainThread:@selector(setImage:) withObject:newImg waitUntilDone:YES];
The result is my video screen stays black. Can anybody see the error here? Ive been at this for a few hours now and cant figure it out.