我尝试从 UIImage 获取 CGContextRef。在调试器中,我的 CGContextRef 始终为 0x0。
这是代码:
NSString *movName = imgName;
NSString *path = [[NSBundle mainBundle] pathForResource:movName ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
CGImageRef imageRef = [image CGImage];
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef);
CGContextRef bitmap = CGBitmapContextCreate(NULL,
100,
100,
CGImageGetBitsPerComponent(imageRef),
CGImageGetBytesPerRow(imageRef),
colorSpaceInfo,
bitmapInfo);
谢谢你的回答