I need to retrieve attributes
dictionary from CVPixelBuffer
. Printing a buffer object shows that the buffer has that dictionary:
(lldb) po imageBuffer
<CVPixelBuffer 0x282985fe0 width=886 height=1920 pixelFormat=420f iosurface=0x281a9def0 planes=2>
<Plane 0 width=886 height=1920 bytesPerRow=896>
<Plane 1 width=443 height=960 bytesPerRow=896>
<attributes={
ExtendedPixelsBottom = 0;
ExtendedPixelsLeft = 0;
ExtendedPixelsRight = 10;
...
};
} propagatedAttachments={
...
} nonPropagatedAttachments={
...
}>
iOS 15 has introduced a new method called CVPixelBufferCopyCreationAttributes
that returns this attributes
field.
Is it possible to achieve the same for the lower targets?
You can get all the information in this way except ExtendedPixels.
CVPixelFormatDescriptionCreateWithPixelFormatType(CFAllocatorRef CV_NULLABLE allocator, OSType pixelFormat)
allocator is nullable
pixelFormat can be obtained by using
CVPixelBufferGetPixelFormatType( CVPixelBufferRef CV_NONNULL pixelBuffer )
For ExtendedPixels information:
CVPixelBufferGetExtendedPixels(
CVPixelBufferRef CV_NONNULL pixelBuffer,
size_t * CV_NULLABLE extraColumnsOnLeft,
size_t * CV_NULLABLE extraColumnsOnRight,
size_t * CV_NULLABLE extraRowsOnTop,
size_t * CV_NULLABLE extraRowsOnBottom )
Hope this answer was helpful