【发布时间】:2019-03-27 03:12:12
【问题描述】:
我使用 CGImageCreate 和 CGColorSpaceCreateDeviceGray 将缓冲区 (CVPixelBufferRef) 转换为灰度图像。它非常快并且在 iOS 12 之前运行良好......现在返回的图像是空的。
代码如下:
bitmapInfo = kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst;
CGDataProviderRef provider = CGDataProviderCreateWithData((void *)i_PixelBuffer,
sourceBaseAddr,
sourceRowBytes * height,
ReleaseCVPixelBuffer);
retImage = CGImageCreate(width,
height,
8,
32,
sourceRowBytes,
CGColorSpaceCreateDeviceGray(),
bitmapInfo,
provider,
NULL,
true,
kCGRenderingIntentDefault);
CGDataProviderRelease(provider);
这是 iOS 12 中的一个已知错误?如果此功能不再支持设备灰色,您能建议我另一种方法吗?
请注意,4K 图像的转换时间应少于 0.1 秒。
提前致谢!
【问题讨论】:
-
我想您可以将缓冲区视为 CIImage 并去饱和或类似。
-
顺便说一句,我想知道这是否与 iOS 12 的新功能有关,其中图形上下文根据您在其中绘制的内容自行配置其深度。这个新功能也给我带来了不小的麻烦。
标签: objective-c core-image ios12