我是iOS编程的新手,我想知道是否可以通过AVFoundation或Xcode中的其他库从相机访问10位或12位原始数据?如果是这样,怎么办?

谢谢!

最佳答案

如果您可以将图像加载到UIImage中,则可以使用Core Graphics获取像素缓冲区。我怀疑它将以每像素16位的形式存储在内存中,但请尝试一下。

UIImage *image = ...

CGImageRef imageRef = image.CGImage;                                     // get the CGImageRef
NSAssert(imageRef, @"Unable to get CGImageRef");

CGDataProviderRef provider = CGImageGetDataProvider(imageRef);           // get the data provider
NSAssert(provider, @"Unable to get provider");

NSData *data = CFBridgingRelease(CGDataProviderCopyData(provider));      // get copy of the data
NSAssert(data, @"Unable to copy image data");

NSInteger       bitsPerComponent = CGImageGetBitsPerComponent(imageRef); // some other interesting details about image
NSInteger       bitsPerPixel     = CGImageGetBitsPerPixel(imageRef);
CGBitmapInfo    bitmapInfo       = CGImageGetBitmapInfo(imageRef);
NSInteger       bytesPerRow      = CGImageGetBytesPerRow(imageRef);
NSInteger       width            = CGImageGetWidth(imageRef);
NSInteger       height           = CGImageGetHeight(imageRef);
CGColorSpaceRef colorspace       = CGImageGetColorSpace(imageRef);

有关更多信息,请参见The Quartz 2D Programming Guide

10-08 03:29