Skip to content

Instantly share code, notes, and snippets.

@caojianhua
Created December 28, 2015 07:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caojianhua/b3fef5a2674898ee3fed to your computer and use it in GitHub Desktop.
Save caojianhua/b3fef5a2674898ee3fed to your computer and use it in GitHub Desktop.
Create CVPixelBuffer from memory
CVPixelBufferRef pxbuffer = NULL;
CVPixelBufferCreateWithBytes(kCFAllocatorDefault,width,height,kCVPixelFormatType_32ARGB,data,4 * width, NULL, NULL, NULL, &pxbuffer);
CIImage* tmpImage = [CIImage imageWithCVPixelBuffer:pxbuffer];
UIImage* newImage = [UIImage imageWithCIImage:tmpImage];
NSLog(@"imageSize:%@",NSStringFromCGSize(newImage.size));
dispatch_async(dispatch_get_main_queue(), ^{
imageView.image = newImage;
imageView.frame = CGRectMake(0, 0, width/5, height);
});
@chengjzh
Copy link

chengjzh commented Mar 9, 2022

Can you provide I420 formart initialize code sample?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment