Post

Replies

Boosts

Views

Activity

CIImage generate CGImage is unavailable
I want to use CIFilter to create a CGImageRef, but when I get cgimage buffer , it is empty CIFilter<CITextImageGenerator> * filter = [CIFilter textImageGeneratorFilter];   filter.text = @"This is a test text";   filter.fontName = @"HoeflerText-Regula";   filter.fontSize = 12;   filter.scaleFactor = 1.0;   CIImage *image = filter.outputImage;   CIContext *context = [CIContext contextWithOptions:nil];   CGImageRef resultRef = [context createCGImage:image fromRect:image.extent];   UIImage *resultImage = [UIImage imageWithCGImage:resultRef];       CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(resultRef));   const unsigned char * buffer = CFDataGetBytePtr(data); And then I could not generate MTLTexture with this cgimage  MTKTextureLoader *loader = [[MTKTextureLoader alloc] initWithDevice:self.device];   NSError*error;   id<MTLTexture> fontTexture = [loader newTextureWithCGImage:resultRef                      options:@{     MTKTextureLoaderOptionOrigin : MTKTextureLoaderOriginFlippedVertically,     MTKTextureLoaderOptionSRGB : @(NO)   }                       error:&error];    How can I finish my work? Any suggestions about this question I am appreciate.
4
0
1.3k
Nov ’22