IOS – Clean CVPixelBuffer

const int kBytesPerPixel = 4;
             CVPixelBufferLockBaseAddress( pixelBuffer, 0 );
             int bufferWidth = (int)CVPixelBufferGetWidth( pixelBuffer );
             int bufferHeight = (int)CVPixelBufferGetHeight( pixelBuffer );
             size_t bytesPerRow = CVPixelBufferGetBytesPerRow( pixelBuffer );
             
             void *baseAddress = CVPixelBufferGetBaseAddress( pixelBuffer );
             
             NSLog(@"------------------ width %d, height %d Row %d", bufferWidth, bufferHeight, bytesPerRow);
             
             for ( int row = 0; row < bufferHeight; row++ )
             {
             uint8_t *pixel = (uint8_t*)baseAddress + row * bytesPerRow;
             for ( int column = 0; column < bufferWidth; column++ )
             {
             // BGRA
             pixel[0] = 0; // BGRA, Blue value
             pixel[1] = 0; // Green value
             pixel[2] = 0; // Red value
             pixel[3] = 0; // alpha value
             
             pixel += kBytesPerPixel;
             }
             }
             
             CVPixelBufferUnlockBaseAddress( pixelBuffer, 0 );

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다