CIContext drawImage does not work

521 Views Asked by At

I am not really aware of CI libraries and only functions descriptions in Apple's documentation is not enough for a person that never worked with graphics or image processing.

I need to be able to process each frame (coming from camera) and put an overlay on each of them with a transformed arrow depending on the processed frame. As a result making a CGImage from a filter every time instead of drawing the CIImage directly, seems a waste of resources and on iPhone 4S I would really need a little bit more performance.

So, in my trial on drawing the CIImage directly by using [context drawImage] got the followings

1) I tried to draw with the context in a simple UIView like below

[context drawImage:arrow inRect:overlayView.frame fromRect:arrow.extent];

The arrow is a valid CIImage that comes from a CIFilter. It is valid because if I transform it into a CGImage, it is projected.

The context looks like this:

    eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

    [EAGLContext setCurrentContext:eaglContext];

    glkView.context = eaglContext;
    glkView.delegate = self;

    NSDictionary *options = @{kCIContextWorkingColorSpace : [NSNull null]};

    context = [CIContext contextWithEAGLContext:eaglContext options:options];

The overlayView is connected and evr is ok with it.

2) after, I tried using a GLKView, with setting the delegate on the ViewController

  • the draw in rect gets called
  • I can modify the glkview color with some basic opengl code

*!! but it never draws my CIImage, even though it is a valid image with size which can be easily transformed into a CGImage

The code for drawing (inside the glkView: drawInRect) is the same

[context drawImage:arrow inRect:glkView.frame fromRect:arrow.extent];

Some suggestions?

0

There are 0 best solutions below