Convert UIImage to CVImageBufferRef

后端 未结 6 703
旧时难觅i
旧时难觅i 2020-12-28 18:09

This code mostly works, but the resulting data seems to loose a color channel (is what I am thinking) as the resulting image data when displayed is tinted blue!

Here

6条回答
  •  情话喂你
    2020-12-28 19:00

    If anyone is still looking for a solution to this problem, I solved it by switching the BOOLs in the pixelBuffer's options:

    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithBool:NO], kCVPixelBufferCGImageCompatibilityKey,
                         [NSNumber numberWithBool:NO], kCVPixelBufferCGBitmapContextCompatibilityKey,
                         nil];
    

    From NO to YES:

    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithBool:YES], kCVPixelBufferCGImageCompatibilityKey,
                         [NSNumber numberWithBool:YES], kCVPixelBufferCGBitmapContextCompatibilityKey,
                         nil];
    

提交回复
热议问题