Converting CIImage to CGImage Too Slow

I need to convert CIImageto CGImage. This is the code I'm currently using:

CGImageRef img = [myContext createCGImage:ciImage fromRect:[ciImage extent]];

But its line of code is very slow for regular sized images. It is very slow that I can use it correctly. Is there another quicker way to convert these CIImagesto CGImages?

In the end, I use Core Graphicsto draw CGImagesup CGContext. If there is a way to draw directly CIImagesbefore CGContext, I think it should also be faster. Is it possible?

thank

+4
source share
2 answers

CIImage:

CIImage , . CIImage "". CIImage , , Core Image , . " " Core Image .

, , , , ( ) CIImage, , , , CGImageRef. , , .

, CIImage - , , , .

, , , , .

Edit

, , (960x540) iPad3, CIColorMap, 60 (~ 16 ).

, CIContext, ColorMapFilter, inputGradientImage ( ) inputImage .

, prepareFrameFiltering , applyFilterToFrame: , .

@property (nonatomic, strong) CIContext *context;
@property (nonatomic, strong) CIFilter *colorMapFilter;

- (void)prepareFrameFiltering {
    self.context = [CIContext contextWithOptions:nil];
    CIImage *colorMap = [CIImage imageWithCGImage:[UIImage imageNamed:@"gradient.jpg"].CGImage];
    self.colorMapFilter = [CIFilter filterWithName:@"CIColorMap"];
    [self.colorMapFilter setValue:colorMap forKey:@"inputGradientImage"];
}

- (void)applyFilterToFrame:(CIImage *)ciFrame {    
    // filter
    [self.colorMapFilter setValue:ciFrame forKey:@"inputImage"];
    CIImage *ciImageResult = [self.colorMapFilter valueForKey: @"outputImage"];

    CGImageRef ref = [self.context createCGImage:ciImageResult fromRect:ciFrame.extent];

    // do whatever you need

    CGImageRelease(ref);
}
+8

CIImage - EAGLContext.

CIImage CGContext , CI , CG . CI GPU CPU, CG .

. , createCGImage: , 4K. , CGContextDrawImage, .

+2

All Articles