2016-08-18 2 views
3

私はフォーマットkCVPixelFormatType_420YpCbCr8BiPlanarFullRangeYCC420fまたはN12)とのCIImageを持っていなかったので、私はこの方法を使用UIImageに変換します私はUIImageにCIImageを変換したいが、私はイメージがどのように見えるかを確認したい今、

CIImage *ciImage = [CIImage imageWithCVPixelBuffer:new_buffer]; 

CIContext *temporaryContext = [CIContext contextWithOptions:nil]; 
CGImageRef videoImage = [temporaryContext 
          createCGImage:ciImage 
           fromRect:CGRectMake(0, 0, 
             CVPixelBufferGetWidth(new_buffer), 
             CVPixelBufferGetHeight(new_buffer))]; 

UIImage *uiImage = [UIImage imageWithCGImage:videoImage]; 

画像のフォーマットがBGRAである場合には、正常に動作していますが、NV12ために、コンソールのエラーメッセージではありません:

Render failed because a pixel format YCC420f is not supported. 

はところで、ciimageはCVPixelBufferRefから来ている、とCVPixelBufferRef GLテクスチャのアドレスに由来する。

ここで、どうすればよいですか?

+0

使用UIImage * uiImage = [[UIImage alloc] initWithCIImage:ciImage]; imageWithCGImage: – AleyRobotics

+0

@Yuri同じ問題。そして、CIImage-> CGImageRef-> UIImageが良いです、imageWithCIImageはエラーメッセージなしで 'nil'を返します。 –

+0

作品形式ios 7:UIImage * uiImage = [[UIImage alloc] initWithCIImage:ciImage]; – Adeel

答えて

0

(IOS 5.0から利用可能な)コードの単純なライン

UIImage * uiImage = [UIImage ALLOC] initWithCIImage:ciImage]。

関連する問題